|
|
|
@ -696,12 +696,23 @@ def parse_kv(args):
|
|
|
|
|
options[k.strip()] = unquote(v.strip())
|
|
|
|
|
return options
|
|
|
|
|
|
|
|
|
|
def _validate_both_dicts(a, b):
|
|
|
|
|
|
|
|
|
|
if not (isinstance(a, dict) and isinstance(b, dict)):
|
|
|
|
|
raise errors.AnsibleError(
|
|
|
|
|
"failed to combine variables, expected dicts but got a '%s' and a '%s'" % (type(a).__name__, type(b).__name__)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def merge_hash(a, b):
|
|
|
|
|
''' recursively merges hash b into a
|
|
|
|
|
keys from b take precedence over keys from a '''
|
|
|
|
|
|
|
|
|
|
result = {}
|
|
|
|
|
|
|
|
|
|
# we check here as well as in combine_vars() since this
|
|
|
|
|
# function can work recursively with nested dicts
|
|
|
|
|
_validate_both_dicts(a, b)
|
|
|
|
|
|
|
|
|
|
for dicts in a, b:
|
|
|
|
|
# next, iterate over b keys and values
|
|
|
|
|
for k, v in dicts.iteritems():
|
|
|
|
@ -1308,6 +1319,8 @@ def listify_lookup_plugin_terms(terms, basedir, inject):
|
|
|
|
|
|
|
|
|
|
def combine_vars(a, b):
|
|
|
|
|
|
|
|
|
|
_validate_both_dicts(a, b)
|
|
|
|
|
|
|
|
|
|
if C.DEFAULT_HASH_BEHAVIOUR == "merge":
|
|
|
|
|
return merge_hash(a, b)
|
|
|
|
|
else:
|
|
|
|
|