summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2016-05-26 12:00:53 -0500
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2016-05-26 16:20:31 -0500
commitbfd69a7042991c0b7feed8997502193b3bbb650e (patch)
treee52cce1ff0cfa8fda81a307f74b3c6d68f356e06 /lib
parent329c62e9141d3b73684e59d03facc26526a0e42c (diff)
downloadansible-bfd69a7042991c0b7feed8997502193b3bbb650e.tar.gz
Modules: check for list-like choices in arg spec
This makes it possible to use anything other than a list (e.g., a tuple, or dict.keys() in py3k) for argument_spec choices. It also improves the error messages if you don't use a list type.
Diffstat (limited to 'lib')
-rw-r--r--lib/ansible/module_utils/basic.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/ansible/module_utils/basic.py b/lib/ansible/module_utils/basic.py
index 9456ad9dc1..63d27281ee 100644
--- a/lib/ansible/module_utils/basic.py
+++ b/lib/ansible/module_utils/basic.py
@@ -1322,14 +1322,14 @@ class AnsibleModule(object):
choices = v.get('choices',None)
if choices is None:
continue
- if type(choices) == list:
+ if isinstance(choices, SEQUENCETYPE):
if k in self.params:
if self.params[k] not in choices:
choices_str=",".join([str(c) for c in choices])
msg="value of %s must be one of: %s, got: %s" % (k, choices_str, self.params[k])
self.fail_json(msg=msg)
else:
- self.fail_json(msg="internal error: do not know how to interpret argument_spec")
+ self.fail_json(msg="internal error: choices for argument %s are not iterable: %s" % (k, choices))
def safe_eval(self, str, locals=None, include_exceptions=False):