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
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
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
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
>
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:
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',
% 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:
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,
On Tue, Apr 18, 2023 at 8:56 AM 'Rowe, Walter P. (Fed)' via Ansible
Project wrote:
>
> TASK [debug]
> ***
> ok: [localhost] => {
> "listb": [
> [
> {
>
---
- 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 }}" ]
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',
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:
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:
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
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:
15 matches
Mail list logo