% 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%7C430da7c2101944514b5008db400de987%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638174200717509337%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=QplBJpgoUM2d3gQ9IZShI5aEwCPgx8A3bmw%2BFfIZyM8%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/6C71BFC3-34D5-4E2A-90E9-1CDB56B3CCE6%40nist.gov.

Reply via email to