有没有人在一个合理的模板中组合了一个循环。 我们想要做的是获得两个组的共同成员,并循环它们来创build我们的configuration。 我们正在尝试在主机限制内工作的相同格式,但接收'dict object' has no attribute 'tag_function_psql:&tag_release_dev'
{% for host in groups['tag_function_psql:&tag_release_dev'] %}
Ansible有intersectfilter。 请参阅Set Theory Filters 。
{% for host in groups['tag_function_psql'] | intersect(groups['tag_release_dev']) %} ... {% endfor %}
我以前在stackoverflow上回答了这个问题