Re: [ansible-project] merging lists

2023-04-18 Thread Vladimir Botka
On Tue, 18 Apr 2023 10:40:40 -0400 Todd Lewis wrote: > - debug: msg="{{ [list_12, list_34, list_56] | sum(start=[]) }}" Isn't *flatten* simpler? - debug: msg="{{ [list_12, list_34, list_56] | flatten }}" -- Vladimir Botka -- You received this message because you are subscribed

Re: [ansible-project] merging lists

2023-04-18 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
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

Re: [ansible-project] merging lists

2023-04-18 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
I just tested and this also works. - debug: msg="{{ [listb] | sum(start=lista) }}" Walter On Apr 18, 2023, at 11:01 AM, Michael DiDomenico 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

Re: [ansible-project] merging lists

2023-04-18 Thread Michael DiDomenico
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 wrote: > > Also, by using the sum() filter: > > [utoddl@tango ansible]$ cat foo.yml > --- > - name: test lists > become: false > gather_facts: false >

Re: [ansible-project] merging lists

2023-04-18 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
Brilliant! Walter -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123 On Apr 18, 2023, at 10:40 AM, Todd Lewis wrote: Also, by using the sum() filter: [utoddl@tango ansible]$ cat foo.yml --- - name: test lists become: false gather_facts: false hosts:

Re: [ansible-project] merging lists

2023-04-18 Thread Todd Lewis
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',

Re: [ansible-project] merging lists

2023-04-18 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
% 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:

Re: [ansible-project] merging lists

2023-04-18 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
This isn't a double expansion of listb. lista and listb happen to have the same values. change one of them and run the playbook to prove it. Walter -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123 On Apr 18, 2023, at 9:07 AM, Michael DiDomenico wrote: On Tue,

Re: [ansible-project] merging lists

2023-04-18 Thread Michael DiDomenico
On Tue, Apr 18, 2023 at 8:56 AM 'Rowe, Walter P. (Fed)' via Ansible Project wrote: > > TASK [debug] > *** > ok: [localhost] => { > "listb": [ > [ > { >

Re: [ansible-project] merging lists

2023-04-18 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
--- - name: test lists become: false gather_facts: false hosts: localhost vars: lista: - { one: 'str1', two: 'str2' } listb: - { one: 'str1', two: 'str2' } tasks: - debug: var=lista - debug: var=listb - set_fact: listb: [ "{{ lista + listb }}" ]

Re: [ansible-project] merging lists

2023-04-18 Thread Dick Visser
On Tue, 18 Apr 2023 at 00:22, Michael DiDomenico wrote: > i want to do this, but i'm not getting exactly what i want > > lista: > - { one: 'str1', two: 'str2' } > > listb: > - "{{ lookup('vars','lista') }}" > - { one: 'str1', two: 'str2' } > > the output i want is > > listb: > { one: 'str1',

Re: [ansible-project] merging lists

2023-04-17 Thread Vladimir Botka
On Mon, 17 Apr 2023 19:29:02 -0400 Michael DiDomenico wrote: > thanks for the help, but that's not exactly what i am after. i'm > attempting to avoid creating a third variable. but maybe that's the > only way You can avoid the third variable if you want to. For example, a: [1, 2, 3] b:

Re: [ansible-project] merging lists

2023-04-17 Thread Michael DiDomenico
thanks for the help, but that's not exactly what i am after. i'm attempting to avoid creating a third variable. but maybe that's the only way On Mon, Apr 17, 2023 at 7:05 PM Vladimir Botka wrote: > > On Mon, 17 Apr 2023 18:22:10 -0400 > Michael DiDomenico wrote: > > > lista: > > - { one:

Re: [ansible-project] merging lists

2023-04-17 Thread Vladimir Botka
On Mon, 17 Apr 2023 18:22:10 -0400 Michael DiDomenico wrote: > lista: > - { one: 'str1', two: 'str2' } > > listb: > - "{{ lookup('vars','lista') }}" > - { one: 'str1', two: 'str2' } > > the output i want is > > listb: > { one: 'str1', two: 'str2' }, > { one: 'str1', two: 'str2' } > > but

[ansible-project] merging lists

2023-04-17 Thread Michael DiDomenico
i want to do this, but i'm not getting exactly what i want lista: - { one: 'str1', two: 'str2' } listb: - "{{ lookup('vars','lista') }}" - { one: 'str1', two: 'str2' } the output i want is listb: { one: 'str1', two: 'str2' }, { one: 'str1', two: 'str2' } but what i get is listb: [ { one: