diff options
author | Peter Sprygada <privateip@users.noreply.github.com> | 2018-11-30 07:22:33 -0500 |
---|---|---|
committer | Toshio Kuratomi <a.badger@gmail.com> | 2018-12-05 10:32:15 -0800 |
commit | 799f8e97b3b0e0340ec4facf78d6da974d3dace9 (patch) | |
tree | c742593577e71bdd60bdd28f1da9d1bb97da2e96 | |
parent | a928ea4d937de6d54b42f455705c262100b72022 (diff) | |
download | ansible-799f8e97b3b0e0340ec4facf78d6da974d3dace9.tar.gz |
fixes an issue with dict_merge in network utils (#41107)
This change address a problem where the dict_merge function would fail
due to the value being a nested dict. This will now recursively pass
the value back through the dict_merge function.
Merge to devel https://github.com/ansible/ansible/pull/41107
(cherry picked from commit 2a4be2748fad885f88163a5b9b1b438fe3cb2ece)
Update changelog
Fix review comments
-rw-r--r-- | changelogs/fragments/49474-network_utils_dict_merge_fix.yaml | 3 | ||||
-rw-r--r-- | lib/ansible/module_utils/network/common/utils.py | 6 |
2 files changed, 8 insertions, 1 deletions
diff --git a/changelogs/fragments/49474-network_utils_dict_merge_fix.yaml b/changelogs/fragments/49474-network_utils_dict_merge_fix.yaml new file mode 100644 index 0000000000..c8baf54e12 --- /dev/null +++ b/changelogs/fragments/49474-network_utils_dict_merge_fix.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: +- fixes an issue with dict_merge in network utils (https://github.com/ansible/ansible/pull/49474) diff --git a/lib/ansible/module_utils/network/common/utils.py b/lib/ansible/module_utils/network/common/utils.py index 1e281bbb15..260b8558f4 100644 --- a/lib/ansible/module_utils/network/common/utils.py +++ b/lib/ansible/module_utils/network/common/utils.py @@ -34,6 +34,7 @@ from itertools import chain from struct import pack from socket import inet_aton, inet_ntoa +from ansible.module_utils.common._collections_compat import Mapping from ansible.module_utils.six import iteritems, string_types from ansible.module_utils.six.moves import zip from ansible.module_utils.basic import AnsibleFallbackNotFound @@ -275,7 +276,10 @@ def dict_merge(base, other): if key in other: item = other.get(key) if item is not None: - combined[key] = dict_merge(value, other[key]) + if isinstance(other[key], Mapping): + combined[key] = dict_merge(value, other[key]) + else: + combined[key] = other[key] else: combined[key] = item else: |