Hurray! thank you, Mr.Maciej
I never thought this simple :)
2014年6月26日木曜日 16時59分59秒 UTC+9 Maciej Delmanowski:
>
> 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] <javascript:>>:
>
>> 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] <javascript:>.
>> To post to this group, send email to [email protected]
>> <javascript:>.
>> 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/6d5ccfc6-62a6-4b3c-a3ff-fbbc8b1dbf7b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.