
[英]ansible, execute a task only if another specific host is also in the playbook run
[英]Run an ansible task on a group of host with each host also passed as an argument to the task
我正在尝试在 Ansible 中找到实现以下目标的方法。
hosts: some_hosts
tasks:
-name: some_task
script: “call/a/script.py {itemised_some_hosts}”
检查是否可以在 ansible 中执行此操作,我需要在 some_hosts 组中的每个主机上一次运行一个脚本,并且需要将每次迭代的组中的主机名传递给脚本。 例如,如果 some_hosts 具有主机名 A、B、C。
然后脚本应该首先在主机 A 上运行,A 作为参数传递给脚本,然后脚本应该在主机 B 上运行,B 作为参数传递,依此类推。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.