cloudera.exe.combine_onto filter – combine two dictionaries

Note

This filter plugin is part of the cloudera.exe collection (version 2.4.1).

It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install cloudera.exe..

To use it in a playbook, specify: cloudera.exe.combine_onto.

Synopsis

  • Create a dictionary (hash/associative array) as a result of merging existing dictionaries.

  • This is the reverse of the ansible.builtin.combine filter.

Input

This describes the input of the filter, the value before | cloudera.exe.combine_onto.

Parameter

Comments

Input

dictionary / required

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 | cloudera.exe.combine_onto(positional1, positional2, ...)

Parameter

Comments

_dicts

list / elements=dictionary / required

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 | cloudera.exe.combine_onto(key1=value1, key2=value2, ...)

Parameter

Comments

list_merge

string

Behavior when encountering list elements.

Choices:

  • "append": append newer entries to the older ones

  • "append_rp": append newer entries to the older ones, overwrite duplicates

  • "keep": discard newer entries

  • "prepend": insert newer entries in front of the older ones

  • "prepend_rp": insert newer entries in front of the older ones, discard duplicates

  • "replace" (default): overwrite older entries with newer ones

recursive

boolean

If True, merge elements recursively.

Choices:

  • false ← (default)

  • true

Notes

Note

  • When keyword and positional parameters are used together, positional parameters must be listed before keyword parameters: input | cloudera.exe.combine_onto(positional1, positional2, key1=value1, key2=value2)

Examples

# ab => {'a':1, 'b':2, 'c': 4}
ab: {{ {'a':1, 'b':2} | cloudera.exe.combine_onto({'b':3, 'c':4}) }}

many: "{{ dict1 | cloudera.exe.combine_onto(dict2, dict3, dict4) }}"

# defaults => {'a':{'b':3, 'c':4}, 'd': 5}
# customization => {'a':{'c':20}}
# final => {'a':{'b':3, 'c':20}, 'd': 5}
final: "{{ customization | cloudera.exe.combine_onto(defaults, recursive=true) }}"

Return Value

Key

Description

Return value

dictionary

Resulting merge of supplied dictionaries.

Returned: success

Authors

  • Webster Mudge (@wmudge)

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.