AnsibleUndefinedVariable

hi,

im running a master/slave cluster where i want to add another slave via ansible so i am limiting the play to the new slave

ansible-playbook -vvv -l mesos_slaves[3] -i hosts-prod.yml playbook.yml -u xxx -k -K

Add a point there comes a template which needs the ips of the other slaves

`

{% for host in groups[‘mesos_slaves’] %}
{{ hostvars[host][‘ansible_eth0’][‘ipv4’][‘address’] }}"
{% endfor %}

`

where mesos_slaves is

`

[mesos_slaves]
slave01
slave02
slave03
slave04

`

The play ends there with

`

fatal: [slave04] => {‘msg’: “AnsibleUndefinedVariable: One or more undefined variables: ‘dict object’ has no attribute ‘ansible_eth0’”, ‘failed’: True}
fatal: [slave04] => {‘msg’: “AnsibleUndefinedVariable: One or more undefined variables: ‘dict object’ has no attribute ‘ansible_eth0’”, ‘failed’: True}

`

but a

`
ansible -i hosts-prod.yml slave01 -m setup -a “filter=eth0

`

gives me

`

slave01 | success >> {
“ansible_facts”: {
“ansible_eth0”: {
“active”: true,
“device”: “eth0”,
“ipv4”: {
“address”: “192.168.0.12”,

`

Why is it not working in the play?

Mike

I'm guessing you are not gathering facts for the others

how can i do it while limiting to one host?

A couple of ways, the simplest would be 2 plays, the first just
gathers facts on all hosts, the 2nd is limited to a single host, facts
are kept in memory cache by default. Another way is just setting up
persistent fact caching.