diff --git a/lib/ansible/utils/vars.py b/lib/ansible/utils/vars.py index 4d44a068c20..73ba52b4b39 100644 --- a/lib/ansible/utils/vars.py +++ b/lib/ansible/utils/vars.py @@ -74,6 +74,12 @@ def merge_hash(a, b): """ _validate_mutable_mappings(a, b) + + # if a is empty or equal to b, return b + if a == {} or a == b: + return b.copy() + + # if b is empty the below unfolds quickly result = a.copy() # next, iterate over b keys and values