インベントリファイル中身↓
[testgroup1]
testhost1
testhost2
[testgroup2]
testhost3
testhost4
[testgroup]
testhost1
testhost2
testhost3
testhost4
プレイブック自体は
host: testgroup
で実行したとして
test1だけコンフィグファイルを分けたいとかって時、
こういう書き方ができるんすねー
## ホスト名がtesthost1だったら実行
- copy: src=usr/local/abc.conf dest=/usr/local/httpd.conf mode=644
when: inventory_hostname == 'testhost1'
↓
これだとtesthost1だと実行される
グループで分ける需要が多そう
## グループ名がtestgroup1のホストだったら実行
- copy: src=usr/local/abc.conf dest=/usr/local/httpd.conf mode=644
when: inventory_hostname in groups['testgroup1']
↓
これだとtestgroup1のtesthost1,testhost2で実行される