Append list variable to another list in Ansible

If you really want to append to content, you will need to use the set_fact module. But if you just want to use the merged lists it is as easy as this:

{{ list1 + list2 }}

With set_fact it would look like this:

- set_fact:
    list_merged: "{{ list1 + list2 }}"

NOTE: If you need to do additional operations on the concatenated lists be sure to group them like so:

- set_fact:
    list_merged: "{{ (list1 + list2) | ... }}"

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)