SUMMARY
jinja2 template issues with hostvars
ISSUE TYPE
- Bug Report
COMPONENT NAME
jinja2 template
ANSIBLE VERSION
ansible 2.7.2
config file = /home/feisa/ansible-linux/ansible.cfg
configured module search path = [u'/home/feisa/ansible-linux/library']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.5 (default, Oct 30 2018, 23:45:53) [GCC 4.8.5 20150623
(Red Hat 4.8.5-36)]
CONFIGURATION
jinja2 template
{% for host in groups['servers_production'] %}
{{ hostvars[host]['ansible_facts']['eth0']['ipv4']['address'] }}
{% endfor %}
- name: Template Knownhosts
template: src=./ssh.j2 dest=/tmp/temp.conf
OS / ENVIRONMENT
Centos 7.6
STEPS TO REPRODUCE
run normal ansible playblook
EXPECTED RESULTS
playbook runs succesfully
ACTUAL RESULTS
{"changed": false, "msg": "AnsibleUndefinedVariable: 'dict object' has no
attribute 'eth0'"}
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/9c75ec4f-e9a8-4140-9817-059fa0b0723c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.