def cfndiff_module_validation(module):
'''
Validate for correct module call/usage in ansible.
'''
# Boto3 is required!
if not HAS_BOTO3:
module.fail_json(msg='boto3 is required. Try pip install boto3')
# cfn_flip is required!
if not HAS_CFN_FLIP:
module.fail_json(msg='cfn_flip is required. Try pip install cfn_flip')
template = module.params['template']
b_template = to_bytes(template, errors='surrogate_or_strict')
# Validate path of template
if not os.path.exists(b_template):
module.fail_json(msg="template %s not found" % (template))
if not os.access(b_template, os.R_OK):
module.fail_json(msg="template %s not readable" % (template))
if os.path.isdir(b_template):
module.fail_json(msg="diff does not support recursive diff of directory: %s" % (template))
return module
评论列表
文章目录