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 <[email protected]> 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 <[email protected]> 
> wrote:
>
> On Tue, Apr 18, 2023 at 8:56 AM 'Rowe, Walter P. (Fed)' via Ansible
> Project <[email protected]> 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 [email protected].
> 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 [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/6C71BFC3-34D5-4E2A-90E9-1CDB56B3CCE6%40nist.gov.
>
>
> --
> 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 [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/4ab442a2-1b5a-5565-fc26-07994cb80dfd%40gmail.com.

-- 
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/CABOsP2P75Ag2e9JCX%3DCRXeiGLybYZnz3mFyu4x97jegzbkMYZg%40mail.gmail.com.

Reply via email to