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

On Thu, 16 Nov 2023 at 12:23, Kathy L <[email protected]> wrote:

> 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?
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/42a382d4-5709-4b2c-9e98-a5512f507da8n%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/42a382d4-5709-4b2c-9e98-a5512f507da8n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAF8BbLbQZ6NkLY4BDqUszq4o85RY5ATcg4cjfucF6W-BOVTiqg%40mail.gmail.com.

Reply via email to