basic: fix ValueError if value of a type='int' is not an int

With this fix, we get a friendly error message:

    failed: [localhost] => {"failed": true}
    msg: value of argument start_port is not of type int and we were unable to automatically convert
pull/11032/head
Rene Moser 10 years ago
parent da6d15d1f9
commit 8f29ca23ae

@ -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…
Cancel
Save