HowTo: combine two lists in vars section/file

Hello together,

i’d like to combine two lists directly in a vars section/file.
I’ve tried the combine filter but as i understood it, it is for dicts and not lists.
Also the union filter did not worked for me as i tried it
I assume that i did something wrong.

Can someone here make the example below fly?

`

To make my request a bit more clear:

I’d like to have the entries of level1keyB in the path list of the hostname bar. The key 'addonpath' is just an guessed construct by me. Maybe this would also work.

- level1keyA:
- hostname: foo
state: present
path:
- left
- hostname: bar
state: present
path:
- righthere
- "{{ entries of level1keyB }}"


But how to do it in practise?

Thank you.

In your second example, you could do this:

`
path: “{{ [‘righthere’] | union(level1keyB) }}”

`

I’m not sure it’s possible in your first example, because to put this in your “WHAT TO WRITE HERE” section you have to access “addonpath” from another part of the same level1keyA data structure, so you end up with a recursive loop error.

Hi John Buxton,

thanks for your reply.
Indeed that worked.

`

Hi,

anyone else got an idea how to solve this?

Thanks in advance

Hi,

to calrify the question here comes a shorten code block

`