# How to access ansible\_$interface where $interface is a registered value?

**URL:** <https://forum.ansible.com/t/how-to-access-ansible-interface-where-interface-is-a-registered-value/15554>\
**Category:** Ansible Project\
**Created:** [June 26, 2014, 7:16am UTC](https://forum.ansible.com/t/how-to-access-ansible-interface-where-interface-is-a-registered-value/15554 "2014-06-26T07:16:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![t\_goto](https://avatars.discourse-cdn.com/v4/letter/t/8491ac/32.png) [@t\_goto](https://forum.ansible.com/u/t_goto)\
**Post date:** [June 26, 2014, 7:16am UTC](https://forum.ansible.com/t/how-to-access-ansible-interface-where-interface-is-a-registered-value/15554/1 "2014-06-26T07:16:02Z")

</div>

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 ☹

---

<div class="post-metadata">

**Author:** ![drybjed](https://avatars.discourse-cdn.com/v4/letter/d/48db29/32.png) [@drybjed](https://forum.ansible.com/u/drybjed)\
**Post date:** [June 26, 2014, 7:59am UTC](https://forum.ansible.com/t/how-to-access-ansible-interface-where-interface-is-a-registered-value/15554/2 "2014-06-26T07:59:53Z")

</div>

Here you go:

---

<div class="post-metadata">

**Author:** ![t\_goto](https://avatars.discourse-cdn.com/v4/letter/t/8491ac/32.png) [@t\_goto](https://forum.ansible.com/u/t_goto)\
**Post date:** [June 26, 2014, 8:08am UTC](https://forum.ansible.com/t/how-to-access-ansible-interface-where-interface-is-a-registered-value/15554/3 "2014-06-26T08:08:01Z")

</div>

Hurray! thank you, Mr.Maciej

I never thought this simple 🙂

2014年6月26日木曜日 16時59分59秒 UTC+9 Maciej Delmanowski:

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [June 26, 2014, 1:02pm UTC](https://forum.ansible.com/t/how-to-access-ansible-interface-where-interface-is-a-registered-value/15554/4 "2014-06-26T13:02:33Z")

</div>

Ansible has not supported $ substitution in a very very long time.

To generate a variable name programatically, do this through hostvars:

{[hostvars[inventory\_hostname][‘ansible\_’ + linked + ‘\_bridge’][‘stdout’][‘ipv4’][‘address’] }}
