combine¶
Collection Note
This module is part of the ansible.builtin collection. To install the collection, use:
Added in version2.0.
Synopsis¶
- Create a dictionary (hash/associative array) as a result of merging existing dictionaries.
Parameters¶
| Parameter | Defaults / Choices | Comments |
|---|---|---|
| _dicts list / elements=dictionary required |
The list of dictionaries to combine. | |
| _input dict required |
First dictionary to combine. | |
| list_merge str |
Default: replace Choices: append, append_rp, keep, prepend, prepend_rp, replace |
Behavior when encountering list elements. |
| recursive bool |
If V(True), merge elements recursively. |
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 Values¶
| Key | Data Type | Description | Returned |
|---|---|---|---|
| _value | dict | Resulting merge of supplied dictionaries. |