Hi,

I am resurrecting this old message (of mine) : the issue 
https://github.com/ansible/ansible/issues/4848 has been closed as "you 
can't do jinja2", but I think this is an issue in gathering ansible_eth1 
fact

any idea ?

Thanks

Le mercredi 6 novembre 2013 17:56:33 UTC+1, Jean Philippe Caruana a écrit :
>
> -----BEGIN PGP SIGNED MESSAGE----- 
> Hash: SHA1 
>
> Hi, 
>
> I successfully managed to add a private IP address on my servers. I 
> can see both network interfaces eth0 and eth1 when I ask for the facts 
> of this server (I stuggled to death to find this command) : 
>
> $ ansible server -m setup -i production 
>         "ansible_eth0": { 
>             "active": true, 
>             "device": "eth0", 
>             "ipv4": { 
>                 "address": "x.x.x.x", 
>                 "netmask": "x.x.x.x", 
>                 "network": "x.x.x.x" 
>             }, 
>             "ipv6": [ 
>                 { 
>                     "address": "x::x:x:x:x", 
>                     "prefix": "64", 
>                     "scope": "link" 
>                 } 
>             ], 
>             "macaddress": "x:x:x:x:x:x", 
>             "module": "e1000e", 
>             "mtu": 1500, 
>             "type": "ether" 
>         }, 
>         "ansible_eth1": { 
>             "active": true, 
>             "device": "eth1", 
>             "ipv4": { 
>                 "address": "x.x.x.x", 
>                 "netmask": "x.x.x.x", 
>                 "network": "x.x.x.x" 
>             }, 
>             "ipv6": [ 
>                 { 
>                     "address": "x::x:x:x:x", 
>                     "prefix": "64", 
>                     "scope": "link" 
>                 } 
>             ], 
>             "macaddress": "x:x:x:x:x:x", 
>             "module": "e1000e", 
>             "mtu": 9000, 
>             "type": "ether" 
>         }, 
>
>
> But when I want to access the "ansible_eth1" fact from my playbook : 
> # dest file is /etc/hosts 
> # locally resolve private IPs 
> {% for host in groups['all'] %} 
> {{ hostvars[host]['ansible_eth1']['ipv4']['address'] }}       {{ host }} 
> {% endfor %} 
>
>
> I get the following error on every single server : 
> fatal: [server] => {'msg': "One or more undefined variables: 'dict 
> object' has no attribute 'ipv4'", 'failed': True} 
>
>
> This kind of code worked really good with eth0 ,as you can see in my 
> fully working iptables template extract : 
> {% for host in groups['all'] %} 
> # access from {{ host }} 
> - -A INPUT -p tcp -m tcp -s {{ 
> hostvars[host]['ansible_eth0']['ipv4']['address'] }} --dport {{ 
> some_port }} -j ACCEPT 
> {% endfor %} 
>
> What am I doing wrong ? 
> How can I debug this ? I thought "ansible server -m setup -i 
> production" would provide me the correct information, but I was wrong. 
>
> Thanks. 
> - -- 
> Jean-Philippe Caruana 
> -----BEGIN PGP SIGNATURE----- 
> Version: GnuPG v1.4.12 (GNU/Linux) 
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ 
>
> iQEcBAEBAgAGBQJSenS/AAoJEJ+Vqztq6gdi8o4IAJTp5BVtk5oiH14ycF3GNCZe 
> kl4aDRbmRwS5vXDE0Bl8/7zWILJLlrvRbwL789GtBrCquTpS7UF733+NiZaPz3GA 
> XAWY15lWo5FtpZ+f0VYmXbSb6ZwcQoTqP7ZhmtAR0+cJMYys5RSwFXadSkR8vX9v 
> D1unQhV9AwgAfNjUaJjfwdy7I8fICsgMIRzhkZjDRD4Q12+j1mnrx/EWZPk5nEX/ 
> yVrvWTrDo2gi/Li+lVZCJB3fFaBJFi+bHV8SMduNcoRJdFlPbEY9EVNRRTqot7YQ 
> W458HRgZYoItCvFa+RVnyZEysTFn6iGpVMLNv9+w8DelHA70jOx9Ghb+2BpvluU= 
> =f8+N 
> -----END PGP SIGNATURE----- 
>

-- 
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/a6c56f5f-d4dd-4312-bbaa-602c27d7f65c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to