New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Undefined variables with three nodes #291
Comments
can you share your variables? |
node0 and node1: `## Monitor options monitor_interface: bond0` node2: `## Monitor options monitor_interface: eth1` When I do "ansible-playbook -s -i production/inventory ceph.yml --limit node0,node1" all is fine, when I don't specify --limit or add node2 also to the limit option the problem arises, quite strange. |
In case I check the vars I can see: ansible all -m setup --tree /tmp/facts -i production/inventory > /tmp/foo
and
so this vars should be there. P.S. In staging I also have three nodes without problems, just in prod (with also three nodes) I have this issue, same code basically, quite strange. |
The problem is related to the fact the some nodes have bond0 other nodes only eth1, if I test with |
Solved. On line 83 in ceph.conf.j2 I had to add the following code: {% if hostvars[host]['ansible_' + monitor_interface] is defined %}
mon addr = {{ hostvars[host]['ansible_' + monitor_interface]['ipv4']['address'] }}
{% endif %} Now all is fine. The problem is that different machines can have different monitoring interfaces and this must be checked before applying the template. |
I'm not sure why this solves your problem. |
in fact it didn't really solve the problem, in the end I've renamed eth1 to bond0 on node2 in order to be in line with the other nodes, now it works, previous fix not required. |
Ok but we should be able to handle such use case where machines are not identical. |
For sure, at least for now we know this fact, better than nothing. |
We've encountered this as well. We tried to overcome it by using monitor_interface: "{{ ansible_default_ipv4.interface }}" but encountered the apparent fact scope problems mentioned in the ansible issues above. Using host_vars gave us the same errors, so it seems that unless we can rename all our interfaces (unlikely) we're stuck with this. |
Hey @snerdish, @ivomarino
|
Hi all,
when I launch "ansible-playbook -s -i production/inventory ceph.yml" with three nodes in the inventory I get this error, with two nodes all seems fine, it's quite strange. Any ideas? Thanks.
TASK: [ceph-common | generate Ceph configuration file] ************************
fatal: [node0] => {'msg': "AnsibleUndefinedVariable: One or more undefined variables: 'dict object' has no attribute u'ansible_eth1'", 'failed': True}
fatal: [node1] => {'msg': "AnsibleUndefinedVariable: One or more undefined variables: 'dict object' has no attribute u'ansible_eth1'", 'failed': True}
fatal: [node2] => {'msg': "AnsibleUndefinedVariable: One or more undefined variables: 'dict object' has no attribute u'ansible_bond0'", 'failed': True}
FATAL: all hosts have already failed -- aborting
The text was updated successfully, but these errors were encountered: