diff options
author | Toshio Kuratomi <toshio@fedoraproject.org> | 2016-02-10 10:51:12 -0800 |
---|---|---|
committer | Toshio Kuratomi <toshio@fedoraproject.org> | 2016-02-10 12:21:32 -0800 |
commit | ba0047a3429738f70e2829216ad4d7694c1f1e54 (patch) | |
tree | 191c8a0ec7b00251feac24444791871075b5b700 | |
parent | 371c7315b07a6b6cac127ba284d8e8d37734be2a (diff) | |
download | ansible-params-default-to-str.tar.gz |
Module params should default to str in most cases.params-default-to-str
-rw-r--r-- | lib/ansible/module_utils/basic.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/ansible/module_utils/basic.py b/lib/ansible/module_utils/basic.py index 4bb376c288..5913d5dbb4 100644 --- a/lib/ansible/module_utils/basic.py +++ b/lib/ansible/module_utils/basic.py @@ -1365,10 +1365,15 @@ class AnsibleModule(object): ''' ensure all arguments have the requested type ''' for (k, v) in self.argument_spec.items(): wanted = v.get('type', None) - if wanted is None: - continue if k not in self.params: continue + if wanted is None: + # 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: + continue + wanted = 'str' value = self.params[k] |