我的意图是在不同的主机中执行每个角色。我正在做一个简单的任务,即在每台主机上下载文件。我有一个主机文件,它看起来像这样Ansible在不同的主机上执行每个角色
[groupa]
10.0.1.20
[groupb]
10.0.1.21
下面
是我main_file.yml文件我的角色
---
- hosts: local
connection: local
gather_facts: no
roles:
- oracle
- apache
结构
main_file.yml
roles
|-- oracle
| |-- tasks
| |-- main.yml
| |-- download_file.yml
|-- apache
| |-- tasks
| |-- main.yml
| |-- download_file.yml
ORACLE/main.yml
---
- name: downloading a file in groupa
hosts: groupa
tasks:
- include: tasks/download_file.yml
oracle/download_file.yml
---
- name: download file
shell: wget http://dummyurl.com/random.sh
对于“groupb”,Apache角色也遵循相同的步骤。但是,当我执行main_file.yml我提示以下错误:
ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path.
The error appears to have been in '/etc/ansible/roles/oracle/tasks/main.yml': line 2, column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
---
- name: downloading a file
^here
您的main.yml没有如所示的调试语句。你能包括整个事情吗? –
即使我只是在oracle/main.yml中添加任何主机而不执行调试任务,我也会得到相同的错误 – shwetha