Commit 9c67396b by John Eskew

Always expect dicts for the tags param.

parent 6697cb1b
...@@ -96,30 +96,27 @@ def main(): ...@@ -96,30 +96,27 @@ def main():
aws_secret_key=dict(aliases=['ec2_secret_key', 'secret_key'], aws_secret_key=dict(aliases=['ec2_secret_key', 'secret_key'],
no_log=True), no_log=True),
aws_access_key=dict(aliases=['ec2_access_key', 'access_key']), aws_access_key=dict(aliases=['ec2_access_key', 'access_key']),
tags=dict(default=None), tags=dict(default=None, type='dict'),
) )
) )
tags_param = module.params.get('tags') tags_param = module.params.get('tags')
import pprint # import pprint
debug_msg = "Before: tags_param type: {} - value: {}".format(type(tags_param), pprint.pformat(tags_param)) # debug_msg = "Before: tags_param type: {} - value: {}".format(type(tags_param), pprint.pformat(tags_param))
module.log(debug_msg) # module.log(debug_msg)
if isinstance(tags_param, basestring): # if isinstance(tags_param, basestring):
tags_param = eval(tags_param) # tags_param = eval(tags_param)
debug_msg += " - After: tags_param type: {} - value: {}".format(type(tags_param), pprint.pformat(tags_param)) # debug_msg += " - After: tags_param type: {} - value: {}".format(type(tags_param), pprint.pformat(tags_param))
module.log(debug_msg) # module.log(debug_msg)
tags = {} tags = {}
if isinstance(tags_param, list): if isinstance(tags_param, dict):
for item in tags_param:
tags.update(item)
elif isinstance(tags_param, dict):
tags = tags_param tags = tags_param
else: else:
module.fail_json(msg="Invalid format for tags. {}".format(debug_msg)) module.fail_json(msg="Invalid format for tags.")
aws_secret_key = module.params.get('aws_secret_key') aws_secret_key = module.params.get('aws_secret_key')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment