# ignoring docker interface when getting interface list

**URL:** <https://forum.ansible.com/t/ignoring-docker-interface-when-getting-interface-list/38584>\
**Category:** Ansible Project\
**Created:** [November 16, 2023, 11:23am UTC](https://forum.ansible.com/t/ignoring-docker-interface-when-getting-interface-list/38584 "2023-11-16T11:23:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kathy\_L](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kathy_l/32/2652_2.png) [@Kathy\_L](https://forum.ansible.com/u/Kathy_L)\
**Post date:** [November 16, 2023, 11:23am UTC](https://forum.ansible.com/t/ignoring-docker-interface-when-getting-interface-list/38584/1 "2023-11-16T11:23:47Z")

</div>

I’m having a problem Docker interface problems while getting a list of interfaces. People on here helped me get the list of interfaces on a device (thank you) like this:

lineinfile:  
dest: “data.txt”  
line: “{{ item }}: {{ ansible\_facts[item].ipv4.address }}”

insertafter: EOF  
delegate\_to: 127.0.0.1  
with\_items: “{{ ansible\_interfaces }}”

The problem is when docker is running, it creates interfaces like this:

veth[UNIQUE ID]

and they don’t have IP addresses. How do I ignore the interface beginning with veth?  
I’ve tried this:

when: "{{ item }} == “^vether”

and  
when: "{{ item }} = “vether.?”

but neither works. How would I do this?

---

<div class="post-metadata">

**Author:** ![dnmvisser](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@dnmvisser](https://forum.ansible.com/u/dnmvisser)\
**Post date:** [November 16, 2023, 1:02pm UTC](https://forum.ansible.com/t/ignoring-docker-interface-when-getting-interface-list/38584/2 "2023-11-16T13:02:42Z")

</div>

Instead of looping over all interfaces and applying a condition to each iteration, you can also filter the list to not include those names.  
It will be cleaner for your output as well. So instead of:

with\_items: “{{ ansible\_interfaces }}”

You could do:

with\_items: “{{ ansible\_interfaces | reject(‘search’,‘^veth’) }}”

Dick

---

<div class="post-metadata">

**Author:** ![Kathy\_L](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kathy_l/32/2652_2.png) [@Kathy\_L](https://forum.ansible.com/u/Kathy_L)\
**Post date:** [November 16, 2023, 3:17pm UTC](https://forum.ansible.com/t/ignoring-docker-interface-when-getting-interface-list/38584/3 "2023-11-16T15:17:39Z")

</div>

I didn’t have any idea you could do that sort of things - thank you. It worked perfectly.
