On Tue, 11 Aug 2020 21:29:40 -0700 (PDT) rajthecomputerguy <[email protected]> wrote:
> ... compare two lists > > list1: > - linux.* > - 6.* > - mysql|python|gvim > > list2: > - linux > - 6.0.1 > - mysql See "Testing strings" and chose from “match”, “search” or “regex”. https://docs.ansible.com/ansible/latest/user_guide/playbooks_tests.html#testing-strings For example, the task below "match" items of the lists - debug: msg: "{{ item.0 is match(item.1) }}" loop: "{{ list2|zip(list1)|list }}" If "compare two lists" means you want to know whether all items match or not, create new list and test all items in it at once. For example https://docs.ansible.com/ansible/latest/user_guide/playbooks_tests.html#test-if-a-list-contains-a-value - set_fact: list3: "{{ list3|default([]) + [item.0 is match(item.1)] }}" loop: "{{ list2|zip(list1)|list }}" - debug: msg: "{{ list3 is all }}" -- Vladimir Botka -- 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/20200812073450.26b5d92c%40gmail.com.
pgp6zef3F3yG7.pgp
Description: OpenPGP digital signature
