Module instance sort en erreur si la procédure n’est pas allé jusqu’au bout

This commit is contained in:
Benjamin Bohard 2021-08-30 11:37:09 +02:00
parent 2e94186bef
commit b553f77ead
1 changed files with 22 additions and 17 deletions

View File

@ -335,6 +335,7 @@ def run_module():
for expectation_name, response in module.params['variables'].items():
expectations.set_expectation_response_by_name(expectation_name, response)
try:
instance_process = pexpect.spawn(cmd, encoding='utf-8', timeout=60)
some_index = 0
@ -353,6 +354,11 @@ def run_module():
some_index += 1
result['changed'] = True
result['msg'] += f"Module {result['module']} instanciated"
module.exit_json(**result)
except Exception as err:
result['msg'] += err
result['changed'] = True
module.fail_json(**result)
@ -369,7 +375,6 @@ def run_module():
# in the event of a successful module execution, you will want to
# simple AnsibleModule.exit_json(), passing the key/value results
module.exit_json(**result)
def main():