Accessing variables of other hosts does not work (for me) on 1.4

Hi all,

Using the info from the document, I tried this but this totally does not work. I tried a few different varibles such as ansible_ipv4 and nothing seemed to work.

{% for host in groups[‘iad2-ads’] %}
server {{ inventory_hostname }} {{ hostvars[host][‘ansible_all_ipv4_address’] }}:80 check
{% endfor %}

Output:

fatal: [iad2-lb2] => {‘msg’: “One or more undefined variables: ‘dict’ object has no attribute ‘ansible_all_ipv4_address’”, ‘failed’: True}
fatal: [iad2-lb2] => {‘msg’: “One or more undefined variables: ‘dict’ object has no attribute ‘ansible_all_ipv4_address’”, ‘failed’: True}
fatal: [iad2-lb3] => {‘msg’: “One or more undefined variables: ‘dict’ object has no attribute ‘ansible_all_ipv4_address’”, ‘failed’: True}
fatal: [iad2-lb3] => {‘msg’: “One or more undefined variables: ‘dict’ object has no attribute ‘ansible_all_ipv4_address’”, ‘failed’: True}
fatal: [iad2-lb4] => {‘msg’: “One or more undefined variables: ‘dict’ object has no attribute ‘ansible_all_ipv4_address’”, ‘failed’: True}
fatal: [iad2-lb4] => {‘msg’: “One or more undefined variables: ‘dict’ object has no attribute ‘ansible_all_ipv4_address’”, ‘failed’: True}
fatal: [iad2-lb1] => {‘msg’: “One or more undefined variables: ‘dict’ object has no attribute ‘ansible_all_ipv4_address’”, ‘failed’: True}
fatal: [iad2-lb1] => {‘msg’: “One or more undefined variables: ‘dict’ object has no attribute ‘ansible_all_ipv4_address’”, ‘failed’: True}

FATAL: all hosts have already failed – aborting

Here is the output from module setup and it clearly show that this variable is available…

ansible iad2-ads -m setup |grep ansible_all_ipv4_address
“ansible_all_ipv4_addresses”: [
“ansible_all_ipv4_addresses”: [
“ansible_all_ipv4_addresses”: [
“ansible_all_ipv4_addresses”: [
“ansible_all_ipv4_addresses”: [
“ansible_all_ipv4_addresses”: [
“ansible_all_ipv4_addresses”: [
“ansible_all_ipv4_addresses”: [
“ansible_all_ipv4_addresses”: [
“ansible_all_ipv4_addresses”: [
“ansible_all_ipv4_addresses”: [
“ansible_all_ipv4_addresses”: [
“ansible_all_ipv4_addresses”: [
“ansible_all_ipv4_addresses”: [
“ansible_all_ipv4_addresses”: [
“ansible_all_ipv4_addresses”: [
“ansible_all_ipv4_addresses”: [
“ansible_all_ipv4_addresses”: [
“ansible_all_ipv4_addresses”: [
“ansible_all_ipv4_addresses”: [
“ansible_all_ipv4_addresses”: [
“ansible_all_ipv4_addresses”: [
“ansible_all_ipv4_addresses”: [
“ansible_all_ipv4_addresses”: [
“ansible_all_ipv4_addresses”: [
“ansible_all_ipv4_addresses”: [

Please help.

Thanks,
Steven.

Let's see what facts you do have ....

ansible -m setup -i <inventory_filename> <hostanme> -a "filter=*ipv4*"

You have two different variable names there: ‘ansible_all_ipv4_address’ and ‘ansible_all_ipv4_addresses’.

Nathan

Hi,

That was a typos on my part in earlier emails.

I definitely think that I found something wrong here:

create /etc/haproxy/bb.cfg] ******************************
fatal: [iad2-lb1] => {‘msg’: “One or more undefined variables: ‘dict’ object has no attribute ‘ansible_default_ipv4’”, ‘failed’: True}
fatal: [iad2-lb1] => {‘msg’: “One or more undefined variables: ‘dict’ object has no attribute ‘ansible_default_ipv4’”, ‘failed’: True}
fatal: [iad2-lb4] => {‘msg’: “One or more undefined variables: ‘dict’ object has no attribute ‘ansible_default_ipv4’”, ‘failed’: True}
fatal: [iad2-lb4] => {‘msg’: “One or more undefined variables: ‘dict’ object has no attribute ‘ansible_default_ipv4’”, ‘failed’: True}
fatal: [iad2-lb3] => {‘msg’: “One or more undefined variables: ‘dict’ object has no attribute ‘ansible_default_ipv4’”, ‘failed’: True}
fatal: [iad2-lb3] => {‘msg’: “One or more undefined variables: ‘dict’ object has no attribute ‘ansible_default_ipv4’”, ‘failed’: True}
fatal: [iad2-lb2] => {‘msg’: “One or more undefined variables: ‘dict’ object has no attribute ‘ansible_default_ipv4’”, ‘failed’: True}
fatal: [iad2-lb2] => {‘msg’: “One or more undefined variables: ‘dict’ object has no attribute ‘ansible_default_ipv4’”, ‘failed’: True}

FATAL: all hosts have already failed – aborting

PLAY RECAP ********************************************************************
to retry, use: --limit @/home/steven/iad2-loadbalancer.retry

iad2-lb1 : ok=4 changed=1 unreachable=1 failed=0
iad2-lb2 : ok=4 changed=1 unreachable=1 failed=0
iad2-lb3 : ok=4 changed=1 unreachable=1 failed=0
iad2-lb4 : ok=4 changed=1 unreachable=1 failed=0

ansible iad2-ads -m setup |grep ansible_default_ipv4
“ansible_default_ipv4”: {
“ansible_default_ipv4”: {
“ansible_default_ipv4”: {
“ansible_default_ipv4”: {
“ansible_default_ipv4”: {
“ansible_default_ipv4”: {
“ansible_default_ipv4”: {
“ansible_default_ipv4”: {

Please make sure there is a github ticket.

– Michael