def main():
    argument_spec = dict(
        host=dict(required=True),
        test=dict(required=True, type='dict')
    )

    module = AnsibleModule(argument_spec)
    test_input = module.params["test"]
    if not HAS_SMOLDER:
        module.fail_json(msg='smolder is required for this module')

    test_obj = Charcoal(test=test_input, host=module.params["host"], output_format='json')
    test_output = json.loads(str(test_obj))
    if test_obj.failed > 0:
        module.fail_json(msg="FOUND {0} FAILURES IN {1} TESTS".format(
            str(test_obj.failed), str(test_obj.passed + test_obj.failed)),
            stdout='\n\033[0m' + test_output['msg'])
    elif test_obj.failed == 0 and test_obj.passed == 0:
        module.fail_json(msg="No tests run: check plugins", stdout='\n\033[0m' + test_output['msg'])
    else:
        module.exit_json(msg="ALL TESTS PASSED!", stdout='\n\033[0m' +
                         test_output['msg'],
                         response_headers=test_output['response_headers'],
                         response_status_code=test_output['response_status_code'],
                         request_inputs=test_output['request_inputs'])
dataset/ETHPy150Open sky-shiny/smolder/ansible-module/smolder.py/main/original