ansible.builtin.combine filter – combine two dictionaries
Note
This filter plugin is part of ansible-core
and included in all Ansible
installations. In most cases, you can use the short
plugin name
combine
.
However, we recommend you use the Fully Qualified Collection Name (FQCN) ansible.builtin.combine
for easy linking to the
plugin documentation and to avoid conflicting with other collections that may have
the same filter plugin name.
Synopsis
Create a dictionary (hash/associative array) as a result of merging existing dictionaries.
Input
This describes the input of the filter, the value before | ansible.builtin.combine
.
Parameter |
Comments |
---|---|
First dictionary to combine. |
Positional parameters
This describes positional parameters of the filter. These are the values positional1
, positional2
and so on in the following
example: input | ansible.builtin.combine(positional1, positional2, ...)
Parameter |
Comments |
---|---|
The list of dictionaries to combine. |
Keyword parameters
This describes keyword parameters of the filter. These are the values key1=value1
, key2=value2
and so on in the following
example: input | ansible.builtin.combine(key1=value1, key2=value2, ...)
Parameter |
Comments |
---|---|
Behavior when encountering list elements. Choices:
|
|
If Choices:
|
Notes
Note
When keyword and positional parameters are used together, positional parameters must be listed before keyword parameters:
input | ansible.builtin.combine(positional1, positional2, key1=value1, key2=value2)
Examples
# ab => {'a':1, 'b':3, 'c': 4}
ab: {{ {'a':1, 'b':2} | ansible.builtin.combine({'b':3, 'c':4}) }}
many: "{{ dict1 | ansible.builtin.combine(dict2, dict3, dict4) }}"
# defaults => {'a':{'b':3, 'c':4}, 'd': 5}
# customization => {'a':{'c':20}}
# final => {'a':{'b':3, 'c':20}, 'd': 5}
final: "{{ defaults | ansible.builtin.combine(customization, recursive=true) }}"
Return Value
Key |
Description |
---|---|
Resulting merge of supplied dictionaries. Returned: success |
Hint
Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up.