-
Notifications
You must be signed in to change notification settings - Fork 20
when in group
TERAOKA Yoshinori edited this page Jan 17, 2014
·
3 revisions
通常、この目的では playbook の hosts でグループを指定しますが、レイヤーの違う複数のグループに所属している場合に困ります。
グループAのサーバーでかつグループBにも入っているサーバーに対してのみ実行したい場合とか、とある role で環境(本番・テスト)によって別の処理をさせたい場合など。
- hosts: group-a
tasks:
- name: ...
action: ...
when: ansible_hostname in group['group-b']
逆(グループに属さない)の場合は not in を使う
when: ansible_hostname not in group['group-b']