Linux – Combine groups in ansible template

ansiblelinuxpython

Has anyone combined groups for a loop in ansible templates. What we want to do is get the common members of two groups and loop them through to create our config. We're trying the same format that works in the host limits but receive 'dict object' has no attribute 'tag_function_psql:&tag_release_dev'

 

{% for host in groups['tag_function_psql:&tag_release_dev'] %}

Best Answer

Ansible has the intersect filter. See Set Theory Filters.

{% for host in groups['tag_function_psql'] | intersect(groups['tag_release_dev']) %}
   ...
{% endfor %}

I answered this previously on stackoverflow

Related Topic