ansible判断主机指定主机组when: inventory_hostname in groups['group']

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.

posted @ 2020-12-09 16:23  技术颜良  阅读(1861)  评论(0编辑  收藏  举报