I’m using variables within the inventory host name to provision environments dynamically using the ansible openstack modules and this is working well
[openstack] myserver-{{env}}.subdomain.mycompany.com
but, when I try to use these hostnames in a jinja2 template snippet, it’s giving me errors
`
- name: find list of openstack servers which
set_fact:
openstack_servers: “{% for host in groups[‘openstack’] %}{{ hostvars[host][‘inventory_hostname’]{% if not loop.last %},{% endif %}{% endfor %}”
`
Is there a way to make it working? Any help or references in this regard will be appreciated ![]()
To replicate this kind of error, run the below play (test.yml) with the below inventory file(inventory.txt)
test.yml
`