On Thu, 30 Jan 2020 10:08:02 -0800 (PST) Rakesh Parida <[email protected]> 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/20200130192918.77680eed%40gmail.com.
pgpqWPKA4r2AN.pgp
Description: OpenPGP digital signature
