From 05caa3654c9c1262dd8250fb041d75706e70887a Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Wed, 31 May 2017 12:37:39 -0400 Subject: [PATCH] fix to alwasy use param in case subpec is used --- lib/ansible/module_utils/basic.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/ansible/module_utils/basic.py b/lib/ansible/module_utils/basic.py index 0df7b1f0925..c8b9c6d5f1c 100644 --- a/lib/ansible/module_utils/basic.py +++ b/lib/ansible/module_utils/basic.py @@ -1723,7 +1723,8 @@ class AnsibleModule(object): if spec is None: spec = self.argument_spec if param is None: - param= self.params + param = self.params + for (k, v) in spec.items(): wanted = v.get('type', None) if k not in param: @@ -1732,7 +1733,7 @@ class AnsibleModule(object): # Mostly we want to default to str. # For values set to None explicitly, return None instead as # that allows a user to unset a parameter - if self.params[k] is None: + if param[k] is None: continue wanted = 'str' @@ -1745,7 +1746,7 @@ class AnsibleModule(object): except KeyError: self.fail_json(msg="implementation error: unknown type %s requested for %s" % (wanted, k)) try: - self.params[k] = type_checker(value) + param[k] = type_checker(value) except (TypeError, ValueError): e = get_exception() self.fail_json(msg="argument %s is of type %s and we were unable to convert to %s: %s" % (k, type(value), wanted, e))