sap / sap.sap_operations / 1.25.0 / filter / combine_default Combine two dictionaries, second dictionary will be used as default. | "added in version" 1.11.0 of sap.sap_operations" Authors: Kirill Satarin (@kksat)sap.sap_operations.combine_default (1.25.0) — filter
Install with ansible-galaxy collection install sap.sap_operations:==1.25.0
collections: - name: sap.sap_operations version: 1.25.0
Combine two dictionaries, second dictionary will be used as default.
If key is present in both dictionaries, value from first dictionary (not value from default) will be used.
If value is not dictionary, it will be returned as is.
If value is None, default will be returned.
This is expected to work only with one level of nesting for dictionaries.
- name: Test filter `combine_default`, this assertion is True ansible.builtin.assert: that: - ( 'ABC' | sap.sap_operations.combine_default('DEF') ) == 'ABC' - ( 123 | sap.sap_operations.combine_default('DEF') ) == 123 - ( [1, 2, 3] | sap.sap_operations.combine_default('DEF') ) == [1, 2, 3] - ( {"key":"value"} | sap.sap_operations.combine_default('DEF') ) == {"key":"value"} - True | sap.sap_operations.combine_default('DEF') == True - False | sap.sap_operations.combine_default('DEF') == False - 0 | sap.sap_operations.combine_default('DEF') == 0 - 1 | sap.sap_operations.combine_default('DEF') == 1 - None | sap.sap_operations.combine_default('DEF') == 'DEF' - value | sap.sap_operations.combine_default(default) == result1 - default | sap.sap_operations.combine_default(value) == result2 vars: value: key1: value1 key2: value2 default: key2: new_value2 key3: value3 result1: key1: value1 key2: value2 key3: value3 result2: key1: value1 key2: new_value2 key3: value3
value: description: Dictionary to combine with default. required: true type: dict default: description: Dictionary to use as default. required: false type: dict
data: description: - Combined dictionary. - If key is present in both dictionaries, value from first dictionary (not value from default) will be used. - If value is not dictionary, it will be returned as is. - If value is None, default will be returned. type: dict