Hi all,
I’m building an HTML report based on a template that looks something like this:
`
{% for i in ansible_play_hosts %}
{{ i }} {{ hostvars[i].ansible_os_name }} {{ hostvars[i].ansible_distribution }} {{ hostvars[i].ansible_env.NUMBER_OF_PROCESSORS }}…
…
`
In case one of the hosts is unreachable, template is not being generated and the following error is being generated:
`
TASK [xxx] *************************************
task path: /etc/ansible/playbooks/xxx.yml:6
fatal: [xxx → localhost]: FAILED! => {“changed”: false, “failed”: true, “invocation”: {“module_args”: {“dest”: “/etc/ansible/playbooks/xxx.txt”, “src”: “/etc/ansible/playbooks/xxx.j2”}, “module_name”: “template”}, “msg”: “AnsibleUndefinedVariable: ‘dict object’ has no attribute ‘ansible_env’”}
…ignoring
`
Any idea how to overcome this? Skip the unreachable host but do successfully generate “dest” file?
Thanks,