diff options
author | Dag Wieers <dag@wieers.com> | 2016-02-18 16:48:15 +0100 |
---|---|---|
committer | Dag Wieers <dag@wieers.com> | 2016-02-18 16:48:15 +0100 |
commit | aeaddc555960eb94ca04a4c34be2780caa472187 (patch) | |
tree | 2ca5c0d0860fc8c6568caafdd01d7c3e959e87af | |
parent | ab0904d051e87fab0a0be481d266cdf1df967a51 (diff) | |
download | ansible-aeaddc555960eb94ca04a4c34be2780caa472187.tar.gz |
Backport combine_vars() logic from Ansible v2.0
While debugging I noticed that _validate_both_dicts() was evaluated twice through combine_vars (when merge_hash). Looking at v2.0 the logic was improved to not do _validate_both_dicts() twice in this case.
I also backported the 'update' behaviour as it looks more pythonic.
-rw-r--r-- | lib/ansible/utils/__init__.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/ansible/utils/__init__.py b/lib/ansible/utils/__init__.py index ffbd8748a7..7f50742d9c 100644 --- a/lib/ansible/utils/__init__.py +++ b/lib/ansible/utils/__init__.py @@ -1485,12 +1485,13 @@ 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: - return dict(a.items() + b.items()) + _validate_both_dicts(a, b) + result = a.copy() + result.update(b) + return result def random_password(length=20, chars=C.DEFAULT_PASSWORD_CHARS): '''Return a random password string of length containing only chars.''' |