Here you go:

---
- hosts: all
  vars:
    interface: 'br0'
  tasks:
    - name: External bridge IP address
      debug: msg="IP address is {{ hostvars[inventory_hostname]['ansible_'
+ interface]['ipv4'].address }}"

Cheers,
Maciej


2014-06-26 9:16 GMT+02:00 t goto <[email protected]>:

> Hello, ansible experts.
> I have a question regarding accessing ansible facts.
>
> I have a system with interface named randomly and dynamically.
> I successfully retrieved int name and registered it to variable.
> Now, I want to know the IP address of it with ansible facts but how can I
> access it?
>
> I tried to access "ansible_$interface" with following code,
> - name: retrieve interface
>    (snip)
>   register: interface
>
> - debug: msg="{{ ansible_$interface.stdout['ipv4']['address']}}"
>
> but all I got was  simple characters.
> ok: [node4] => {
>     "msg": "{{ansible_$linked_bridge.stdout['ipv4']['address']}}"
> }
>
>
> I know it's a very fundamental question, but this variable problems always
> get in my way :(
>
> --
> 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/51e4d68c-0d57-4b8a-afc2-08b11a9b161d%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/51e4d68c-0d57-4b8a-afc2-08b11a9b161d%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAEnKK1wy6DBEGPk_cSQW0MmyAY0w-d73u%2Bbi0_3-%2Bqqtkz8P%3DA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to