Unable to extract host facts

35 views
Skip to first unread message

Gordon Ross

unread,
Dec 2, 2014, 6:30:35 PM12/2/14
to ansible...@googlegroups.com
I’m running Ansible 1.4.4 which comes with Ubuntu 12.04 LTS. I’m getting weird results when trying to get host facts.

If I have:

- debug: var=hostvars[inventory_hostname]

I get the all the information I’d expect, including:

ok: [test.example.com] => {
"hostvars[inventory_hostname]": {

"ansible_eth0": {
"active": true,
"device": "eth0",
"ipv4": {
"address": “192.168.1.1",
"netmask": "255.255.255.0",
"network": “192.168.1.254"
},
….

but if I have:

- debug: var=hostvars[inventory_hostname]['ansible_eth0’]

ok: [test.example.com] => {
"hostvars[inventory_hostname][ansible_eth0]": "{{ hostvars[inventory_hostname][ansible_eth0] }}",
"item": "”
}

i.e. Nothing!

I also tried

- debug: msg={{hostvars[inventory_hostname]['ansible_eth0’]}}

and got the same result.

I did a google and didn’t find anything promising.

Any suggestions as to what I’m doing wrong?

Thanks,

GTG
--
Gordon Ross



--
Gordon Ross,
UIS Telecoms Office,
University of Cambridge

Brian Coca

unread,
Dec 2, 2014, 6:33:21 PM12/2/14
to ansible...@googlegroups.com
try this:

- debug: var=ansible_eth0


--
Brian Coca

Gordon Ross

unread,
Dec 3, 2014, 2:58:35 AM12/3/14
to ansible...@googlegroups.com
On 2 Dec 2014, at 23:33, Brian Coca <bc...@ansible.com> wrote:

> try this:
>
> - debug: var=ansible_eth0

Sorry, that doesn’t work:

fatal: [test.example.com] => {'msg': "One or more undefined variables: 'dict object' has no attribute 'ansible_eth0'", 'failed': True}

GTG
--
Gordon Ross

Brian Coca

unread,
Dec 3, 2014, 7:53:32 AM12/3/14
to ansible...@googlegroups.com
are both tasks in the same play? have you gathered facts?
--
Brian Coca

Michael DeHaan

unread,
Dec 3, 2014, 11:16:05 AM12/3/14
to ansible...@googlegroups.com
ansible 1.4.4 is an old version of Ansible, if you are still having problems on the 1.8.X series, please let us know.




--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAJ5XC8maMxu8upcpCKP6r8vDH6K9Ak5SKhLgu0D7hrihuBMOgw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages