Hi,
I am using Ansible v1.7.1.
I am having trouble using the gathered facts when an interface has bonding and VLANs enabled:
ansible -m setup testserver
[…]
“ansible_bond0.11”: {
“active”: true,
“device”: “bond0.11”,
“ipv4”: {
“address”: “192.168.11.66”,
“netmask”: “255.255.255.0”,
“network”: “192.168.11.0”
},
“macaddress”: “d4:ae:52:98:71:1f”,
“mtu”: 1500,
“promisc”: false,
“type”: “ether”
},
[…]
Then, I have a playbook that sets a variable:
Example from a different server that doesn’t have bonding or VLANs:
listen_ip: “{{ ansible_eth1.ipv4.address }}”
Example that doesn’t work:
listen_ip: “{{ ansible_bond0.11.ipv4.address }}”
Ansible output:
fatal: [testserver] => {‘msg’: ‘AnsibleUndefinedVariable: One or more undefined variables: dict object has no element 11’, ‘failed’: True}
fatal: [testserver] => {‘msg’: ‘AnsibleUndefinedVariable: One or more undefined variables: dict object has no element 11’, ‘failed’: True}
FATAL: all hosts have already failed – aborting
I have tried different possibilities but they all failed:
“{{ ansible_bond0.11.ipv4.address }}”
“{{ ansible_bond0\.11.ipv4.address }}”
“{{ [ansible_bond0.11].ipv4.address }}”
“{{ {ansible_bond0.11}.ipv4.address }}”
“{{ ‘ansible_bond0.11’.ipv4.address }}”
I think Ansible is taking the VLAN tag as part of the subgroup in the config…
What is the correct way of selecting the IPv4 address of a bond0.11 interface?
Thank you in advanced.
Best regards,
J.