Могу ли я использовать что-то, как показано ниже в ansible:
---
- hosts: webserver
gather_facts: False
tasks:
- name: Check ping
shell: ansible -i localhost.yml -m shell -a 'ping'
Этот localhost содержит все хосты, тогда как playbook будет работать на веб-сервере.
Фактическое требование - запуск на веб-сервере, тогда как в одна задача мне нужно выполнить команду на всех хостах, указанных в файле хоста.
Заранее спасибо!
Просто добавить ошибку:
fatal: [webservice]: FAILED! => {
"changed": true,
"cmd": "ansible -i localhost.yml -m shell -a 'ping'",
"delta": "0:00:00.009121",
"end": "2020-02-12 04:47:06.174390",
"invocation": {
"module_args": {
"_raw_params": "ansible -i localhost.yml -m shell -a 'ping'",
"_uses_shell": true,
"argv": null,
"chdir": null,
"creates": null,
"executable": null,
"removes": null,
"stdin": null,
"stdin_add_newline": true,
"strip_empty_ends": true,
"warn": true
}
},
"msg": "non-zero return code",
"rc": 127,
"start": "2020-02-12 04:47:06.165269",
"stderr": "ansible: not found",
"stderr_lines": [
"ansible: not found"
],
"stdout": "",
"stdout_lines": [] }