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/11093/head
Rene Moser 10 years ago committed by Brian Coca
parent 9a88e0fc8e
commit 8da580a29c

@ -1016,6 +1016,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)
@ -1067,6 +1068,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