And if you really wanted only unique list items this also works ... - debug: msg="{{ [listb] | sum(start=lista) | unique }}"
Walter -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123 On Apr 18, 2023, at 12:44 PM, 'Rowe, Walter P. (Fed)' via Ansible Project <ansible-project@googlegroups.com> wrote: I just tested and this also works. - debug: msg="{{ [listb] | sum(start=lista) }}" Walter On Apr 18, 2023, at 11:01 AM, Michael DiDomenico <mdidomeni...@gmail.com> wrote: agreed, brillant. i'll give that a whirl, but it looks like exactly what i'm after. thanks On Tue, Apr 18, 2023 at 10:40 AM Todd Lewis <uto...@gmail.com> wrote: Also, by using the sum() filter: [utoddl@tango ansible]$ cat foo.yml --- - name: test lists become: false gather_facts: false hosts: localhost vars: list_12: - { one: 'str1', two: 'str2' } list_34: - { three: 'str3', four: 'str4' } list_56: - { five: 'str5', six: 'str6' } tasks: - debug: msg="[ {{ list_12, list_34, list_56 }} ]" - debug: msg="{{ [list_12, list_34, list_56] | sum(start=[]) }}" [utoddl@tango ansible]$ ansible-playbook foo.yml PLAY [test lists] *************************************************************** TASK [debug] ******************************************************************** ok: [localhost] => { "msg": [ [ [ { "one": "str1", "two": "str2" } ], [ { "four": "str4", "three": "str3" } ], [ { "five": "str5", "six": "str6" } ] ] ] } TASK [debug] ******************************************************************** ok: [localhost] => { "msg": [ { "one": "str1", "two": "str2" }, { "four": "str4", "three": "str3" }, { "five": "str5", "six": "str6" } ] } PLAY RECAP ********************************************************************** localhost : ok=2 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 On 4/18/23 9:10 AM, 'Rowe, Walter P. (Fed)' via Ansible Project wrote: % cat foo.yml --- - name: test lists become: false gather_facts: false hosts: localhost vars: lista: - { one: 'str1', two: 'str2' } listb: - { three: 'str3', four: 'str4' } tasks: - debug: var=lista - debug: var=listb - set_fact: listb: [ "{{ lista + listb }}" ] - debug: var=listb % ansible-playbook foo.yml PLAY [test lists] ****************************************************************************************************** TASK [debug] *********************************************************************************************************** ok: [localhost] => { "lista": [ { "one": "str1", "two": "str2" } ] } TASK [debug] *********************************************************************************************************** ok: [localhost] => { "listb": [ { "four": "str4", "three": "str3" } ] } TASK [set_fact] ******************************************************************************************************** ok: [localhost] TASK [debug] *********************************************************************************************************** ok: [localhost] => { "listb": [ [ { "one": "str1", "two": "str2" }, { "four": "str4", "three": "str3" } ] ] } PLAY RECAP ************************************************************************************************************* localhost : ok=4 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 Walter -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123 On Apr 18, 2023, at 9:07 AM, Michael DiDomenico <mdidomeni...@gmail.com> wrote: On Tue, Apr 18, 2023 at 8:56 AM 'Rowe, Walter P. (Fed)' via Ansible Project <ansible-project@googlegroups.com> wrote: TASK [debug] *********************************************************************************************************** ok: [localhost] => { "listb": [ [ { "one": "str1", "two": "str2" }, { "one": "str1", "two": "str2" } ] ] } i got to this point as well in my testing, but the double list expansion of listb is a problem. -- 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 ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fansible-project%2FCABOsP2O0HyQCBDnpJ5a2KK9RsUttdf6M0AgYcEFsZfGeJiMrww%2540mail.gmail.com&data=05%7C01%7Cwalter.rowe%40nist.gov%7C485b6aa4280745a02dda08db401ddc97%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638174269233621933%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=4PX%2FuEvuX5PHjjjVlBHdrdoAIOvZnZ6Ctxleps7eFMU%3D&reserved=0. -- 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 ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fansible-project%2F6C71BFC3-34D5-4E2A-90E9-1CDB56B3CCE6%2540nist.gov&data=05%7C01%7Cwalter.rowe%40nist.gov%7C485b6aa4280745a02dda08db401ddc97%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638174269233621933%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=MGN%2BWN4bk12PZMoRb486y%2BXfpQNAcTfN0ZebMjgWc3Q%3D&reserved=0. -- Todd -- 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 ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fansible-project%2F4ab442a2-1b5a-5565-fc26-07994cb80dfd%2540gmail.com&data=05%7C01%7Cwalter.rowe%40nist.gov%7C485b6aa4280745a02dda08db401ddc97%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638174269233621933%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=O11zJ6yw8EWoTPIccmHn8gpwx3peu%2BgXeX4NPh5hsbk%3D&reserved=0. -- 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 ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fansible-project%2FCABOsP2P75Ag2e9JCX%253DCRXeiGLybYZnz3mFyu4x97jegzbkMYZg%2540mail.gmail.com&data=05%7C01%7Cwalter.rowe%40nist.gov%7C485b6aa4280745a02dda08db401ddc97%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638174269233934388%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=yCuwp9ZbStAtjstrQXdhgyq5wcjv8lFfbMkXTcJ9O7M%3D&reserved=0. -- 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 ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/FC476FE3-4A0D-4868-9B25-BC5237FD0386%40nist.gov. -- 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 ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/77E799BB-EA84-40DD-BCE9-5920865B062D%40nist.gov.