有时候,在一个playbook中,我们希望不同的host group 可以对应不同的role,则可以使用以下方法:
# applied to all hosts
- hosts: all
gather_facts: yes
roles:
- prerequsites-for-all
# only applied to 'myrole' group
- hosts: myrole
roles:
- role: echo
也可以:
- hosts: all
gather_facts: yes
roles:
- prerequisites-for-all
- { role: echo, when: "'myrole' in group_names" }
原文: Ansible: applying roles to certain groups in a single playbook
网友评论