Answer the question
In order to leave comments, you need to log in
What could be wrong with my ansible?
Hello. I came across an interesting problem.
Input data (ansible 2.2):
1. Inventory
[api]
api01.domain.tld max_fails=12 fail_timeout=70
api02.domain.tld max_fails=13 fail_timeout=70
api03.domain.tld max_fails=12 fail_timeout=70
api04.domain.tld max_fails=12 fail_timeout=70
{% for upstream1 in nginx_upstreams1.iteritems() %}
upstream {{ upstream1[0] }} {
{% for item in upstream1[1] %}
{{ item }};
{% endfor %}
{% for host in groups[upstream1[0]] %}
# {{ host }}
server {{ hostvars[host].ansible_eth0.ipv4.address }} ;
{{ hostvars[host].max_fails }}
{% endfor %}
}
{% endfor %}
# max_fails {{ hostvars['api01.domain.tld'].max_fails }}
# max_fails {{ hostvars['api02.domain.tld'].max_fails }}
{{ hostvars[host].max_fails }}
- gives "msg": "AnsibleUndefinedVariable: 'dict object' has no attribute 'max_fails'" Answer the question
In order to leave comments, you need to log in
I suppose that instead of {{ hostvars[host].max_fails }}, you just need to write {{ max_fails }}
Depending on the current apiXX.domain.tld, the required max_fails will be taken.
it is obvious that the facts were not collected from the api if it swears at such an error
, the api section is probably empty
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question