mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #11032 from resmo/fix/value_error
basic: fix ValueError if value of a type='int' is not an int
This commit is contained in:
commit
9ec5299c12
1 changed files with 52 additions and 49 deletions
|
@ -1015,6 +1015,7 @@ class AnsibleModule(object):
|
|||
value = self.params[k]
|
||||
is_invalid = False
|
||||
|
||||
try:
|
||||
if wanted == 'str':
|
||||
if not isinstance(value, basestring):
|
||||
self.params[k] = str(value)
|
||||
|
@ -1066,6 +1067,8 @@ class AnsibleModule(object):
|
|||
|
||||
if is_invalid:
|
||||
self.fail_json(msg="argument %s is of invalid type: %s, required: %s" % (k, type(value), wanted))
|
||||
except ValueError, e:
|
||||
self.fail_json(msg="value of argument %s is not of type %s and we were unable to automatically convert" % (k, wanted))
|
||||
|
||||
def _set_defaults(self, pre=True):
|
||||
for (k,v) in self.argument_spec.iteritems():
|
||||
|
|
Loading…
Reference in a new issue