To use a hostvar that contains a '.' you will need to do something such as:

{{ hostvars[inventory_hostname]['ansible_bond0.11']['ipv4']['address'] }}

On Tue, Nov 4, 2014 at 1:51 PM, Joel Sdc <[email protected]> wrote:

> 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.
>
>  --
> 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/15e60e0b-879b-4ce2-8935-717f5be40cf7%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/15e60e0b-879b-4ce2-8935-717f5be40cf7%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Matt Martz
@sivel
sivel.net

-- 
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/CAD8N0v_ohv%2B5czaYvmg2%2BV_%3DvQcR-iT8GLt1ctHQeVnyskr%3DgQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to