Unable to extract host facts

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

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

are both tasks in the same play? have you gathered facts?

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.