jinja2 - Append list variable to another list in Ansible -
is possible append variable list static list in ansible?
i can define whole list variable:
my_list: - 1 - 2 - 3
and use in playbook as
something: {{my_list}}
but cannot seem find how (pseudo code):
list_to_append: - 3 - 4
and in playbook:
something: - 1 - 2 - {{append: list_to_append}}
if in fact impossible, suggest use case?
i have list of items in parameter, of them optional
, should modifiable using variables.
in other words: have default values
+ optional values
or not added via variables.
the optional values
not known in advance, add 1, 2 or 100 of them, not static.
i have default static list ++ configurable variable list append.
edit: found it's with_items , need in normal parameter:
with_flattened: - "{{list1}}" - "{{list2}}"
if want append content, need use set_fact
module. if want use merged lists easy this:
{{ list1 + list2 }}
with set_fact
this:
- set_fact: list_merged: "{{ list1 + list2 }}"
Comments
Post a Comment