Hello Adam E,

You have got the implementation correct. Intersect is the correct method to 
be used.  
You may refer the playbook mentioned below: 

---
- hosts: localhost
  vars:
        list1: ['value1', 'value2]
        list2: ['value3', 'value4']

  tasks:
  - name: intersrction
    debug:
     msg: "{{ list1 | intersect(list2) | length > 0}}"
    register: List

  - name: Print message
    debug:
      msg: "{{ List }}"

Thanks
Soniya

On Thursday, April 4, 2019 at 4:19:50 AM UTC+5:30, Adam E wrote:
>
> Hi, wondering if there is any cleaner way to see if two lists have 1 or 
> more intersecting values?
>
> the following works for me
>
> # returns true
>> {{ ['value1', 'value2'] | intersect(['value1', 'value2']) | length > 0 }}
>> # returns false
>> {{ ['value3', 'value4'] | intersect(['value1', 'value2']) | length > 0 }}
>
>
> just wondering if there is a cleaner looking solution that I am not aware 
> of as I am using it frequently.  
> something like would be handy. 
>
>> {{ ['value1', 'value2].any(['value1', 'value2']) }}
>
>

-- 
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/24264dea-2742-4e6d-84a8-c3ae77ac4afc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to