目标是限制主机组在剧本中运行。以下代码不会将组限制为组群集,有时下面的playbook也会在localhost上运行
然后在所需的主机组上运行
- hosts: cluster,cluster1,cluster2 gather_facts: no tasks: ...
或者在清单中,您可以通过以下方式对主机组进行分组:
[cluster] ip1 ip2 ip3 [clusters:children] cluster cluster1
然后在上面运行剧本 集群 组