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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM