Hi Vladimir,

If my items of lists are not fixed on both the list ,  how do i compare 
them:
Now i have one more issue on the LIST comparison:
If the numbers of items in list is not equal is there way to compare:

suppose my lists are:
      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-service-default-3.1.37-1911141021_63e48.noarch"

    - name: If the List comparision is not equal
      debug:
        msg: "{{ item.0 }} is not equal to {{ item.1 }}"
      loop: "{{ list1|sort|zip(list2|sort)|list }}"
      when: item.0.split('-')[-1] is not version(item.1.split('-')[-2])
     
As you can see the items are not same in both list.
  

 

On Thursday, January 30, 2020 at 11:59:37 PM UTC+5:30, Vladimir Botka wrote:
>
> On Thu, 30 Jan 2020 10:08:02 -0800 (PST) 
> Rakesh Parida <[email protected] <javascript:>> wrote: 
>
> > Is there any way the list comparision would be successful even if the 
> > sequence is altered. 
> > 
> >         list1: 
> >           - iam-python-common-1.0.0 
> >           - iam-service-default-3.1.42 
> >           - dp-steps-common-3.0.12 
> >         list2: 
> >           - dp-steps-common-3.0.15-1911280809_d103a.noarch 
> >           - iam-service-default-3.1.37-1911141021_63e48.noarch 
> >           - iam-python-common-1.0.1-1910242116.noarch 
>
> Sure. Sort the lists. For example 
>
>      - debug: 
>          msg: "{{ item.0 }} is not equal to {{ item.1 }}" 
>        loop: "{{ list1|sort|zip(list2|sort)|list }}" 
>        when: item.0.split('-')[-1] is not version(item.1.split('-')[-2]) 
>
> gives 
>
>     "msg": "dp-steps-common-3.0.12 is not equal to 
>     dp-steps-common-3.0.15-1911280809_d103a.noarch" 
>     "msg": "iam-python-common-1.0.0 is not equal to 
>     iam-python-common-1.0.1-1910242116.noarch" 
>     "msg": "iam-service-default-3.1.42 is not equal to 
>     iam-service-default-3.1.37-1911141021_63e48.noarch" 
>
> 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/b8e2d62c-ae99-4c0e-8cda-4ac4056bf766%40googlegroups.com.

Reply via email to