ansible判断对指定主机组执行task , when: inventory_hostname in {{ groups['group'] }} does not work with dynamic inventory

So just did a lot of experimenting and found

Works:

when: inventory_hostname in groups['group']

Fails:
when: inventory_hostname in {{ groups['group'] }}

So it is the extra set of {{ }} that causes the problem. Although I don't know why it works for static but not for dynamic.

 

参考:https://github.com/ansible/ansible/issues/11371

posted @ 2020-01-08 15:17  Oops!#  阅读(1911)  评论(0编辑  收藏  举报