我的意圖是在不同的主機中執行每個角色。我正在做一個簡單的任務,即在每臺主機上下載文件。我有一個主機文件,它看起來像這樣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