HI Vladimir,

Thanksfor your reply.

Actually this is not what i want , i just want my item1 to not to iterate 
over the loop and compare every item, it should only compare the relative 
item2.
PLs check my o/p.
I just only want the o/p:
"msg": " dp-steps-common-3.0.12 is not equal to 
dp-steps-common-3.0.15-1911280809_d103a.noarch"

Regards
Rakesh

On Thursday, January 30, 2020 at 7:21:06 PM UTC+5:30, Vladimir Botka wrote:
>
> On Thu, 30 Jan 2020 04:49:02 -0800 (PST) 
> Rakesh Parida <[email protected] <javascript:>> wrote: 
>
> > Hi , 
> > 
> > I want to compare two lists. 
> > [...] 
> > my playbook: 
> > - hosts: localhost 
> >   tasks: 
> >     - name: Create a list1 
> >       set_fact: 
> >         list1: 
> >           - dp-steps-common-3.0.12 
> >           - iam-python-common-1.0.1 
> >           - iam-service-default-3.1.37 
> >         list2: 
> >           - dp-steps-common-3.0.15-1911280809_d103a.noarch 
> >           - iam-python-common-1.0.1-1910242116.noarch 
> >           - iam-service-default-3.1.37-1911141021_63e48.noarch 
>
> Is this what you're looking for? 
>
>      - debug: 
>          msg: "{{ item }} is in the list2" 
>        loop: "{{ list1 }}" 
>        when: list2|select('match', item)|list 
>
> gives 
>
>     "msg": "iam-python-common-1.0.1 is in the list2" 
>     "msg": "iam-service-default-3.1.37 is in the list2 
>
> HTH, 
>
>         -vlado 
>

-- 
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/67ce9ac8-33cb-4772-ad14-59e28933af2d%40googlegroups.com.

Reply via email to