Syntax for adding lists in playbook

10 views
Skip to first unread message

Johannes Kastl

unread,
Jan 3, 2017, 10:55:45 AM1/3/17
to ansible...@googlegroups.com
Dear all,

I have a task that is supposed to be running with_nested, aka with two
lists it should loop through:

###############################
- name: "Some task with_nested"
...
with_nested:
- "{{ first_variable }}"
- { ".config/", ".config/autostart-scripts/",
".config/plasma-workspace/", ".config/plasma-workspace/shutdown/" }
###############################

The variable first_variable is defined elsewhere.

In order to avoid a looooong line containing all .config-directories,
I tried adding the second list as above. But it fails, it just uses
the literal string "second_list".

###############################
- name: "Some task with_nested"
...
with_nested:
- "{{ first_variable }}"
- second_list:
- ".config/"
- ".config/autostart-scripts/"
- ".config/plasma-workspace/"
- ".config/plasma-workspace/shutdown/"
###############################

How should the syntax be to achieve readability and correct looping?

Thanks,
Johannes

signature.asc

Johannes Kastl

unread,
Jan 3, 2017, 11:06:06 AM1/3/17
to ansible...@googlegroups.com
On 03.01.17 16:55 Johannes Kastl wrote:
> How should the syntax be to achieve readability and correct looping?

I answer myself, seems I had a typo in there somewhere.

This works:
###############################
- name: "Some task with_nested"
...
with_nested:
- "{{ first_variable }}"
- [
".config/",
".config/autostart-scripts/",
".config/plasma-workspace/",
".config/plasma-workspace/shutdown/"
]
###############################

Thanks for listening ;-)

Johannes

signature.asc
Reply all
Reply to author
Forward
0 new messages