I apologize I did miss a line in my task when I copied.  So I used the
(Port|Vlan).  Which again works as a single statement.  Also tried putting
the statements in ()

    - name: Apply policy to the interfaces
      cisco.ios.ios_config:
        parents: interface {{ item.key }}
        lines:
          - device-tracking attach-policy IPDT_POLICY
      loop: "{{ netbrain_interface_attributes|dict2items }}"
      when: >
        item.key is not regex("(Port|Vlan)")
        or item.key not in po_ints

    - name: Apply policy to the interfaces
      cisco.ios.ios_config:
        parents: interface {{ item.key }}
        lines:
          - device-tracking attach-policy IPDT_POLICY
      loop: "{{ netbrain_interface_attributes|dict2items }}"
      when: >
        (item.key is not regex("(Port|Vlan)"))
        or (item.key not in po_ints)

On Wed, Nov 25, 2020 at 10:08 AM Stefan Hornburg (Racke) <[email protected]>
wrote:

> On 11/25/20 4:44 PM, [email protected] wrote:
> > In an ansible play, is "or" not supported with conditional statements? I
> have a task that is searching a variable for 2
> > values. The when statements work alone, but with "or" it runs but
> doesn't do what I am expecting. Here is the task, is
> > my syntax wrong or is it just not supported? -
> >
> >
> >     - name: Apply policy to the interfaces
> >       cisco.ios.ios_config:
> >         parents: interface {{ item.key }}
> >         lines:
> >           - device-tracking attach-policy IPDT_POLICY
> >       loop: "{{ netbrain_interface_attributes|dict2items }}"
> >       when: >
> >         item.key is not search("Port")
> >         or item.key is not search("Vlan")
> >
>
> Maybe you need ( ) around both conditions, but you can also use (untested)
>
>    item.key is not regex("(Port|Vlan)")
>
> Regards
>        Racke
>
> >
> > --
> > 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] <mailto:
> [email protected]>.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/ansible-project/a0649fd5-6757-4e91-9424-904629aad1fdn%40googlegroups.com
> > <
> https://groups.google.com/d/msgid/ansible-project/a0649fd5-6757-4e91-9424-904629aad1fdn%40googlegroups.com?utm_medium=email&utm_source=footer
> >.
>
>
> --
> Ecommerce and Linux consulting + Perl and web application programming.
> Debian and Sympa administration. Provisioning with Ansible.
>
> --
> 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/81625ee8-3b31-a6b7-dc30-50b4db9b5d72%40linuxia.de
> .
>

-- 
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/CAANJ-QSLQnb5NKqmM6wnEyc-5ZY7wmLitjB4TZJripm%3D7dmoyw%40mail.gmail.com.

Reply via email to