From 1ae799f3618d04affdbc08bc69f2dbfbeab75e8d Mon Sep 17 00:00:00 2001 From: Kamil Madac Date: Sun, 14 Jun 2015 19:48:00 +0200 Subject: [PATCH] Better error handling in supervisorctl module. If execution of supervisorctl was not successful (exit code > 0), module silently supress this error and returns changed = false, which turns to OK task state. This is very confusing, when supervisorctl needs authentication, and credentials are not specified in module or are incorrect, services are not restarted/started/stopped without raising an error. --- lib/ansible/modules/web_infrastructure/supervisorctl.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/web_infrastructure/supervisorctl.py b/lib/ansible/modules/web_infrastructure/supervisorctl.py index f75992b9a6a..ef86eec26a7 100644 --- a/lib/ansible/modules/web_infrastructure/supervisorctl.py +++ b/lib/ansible/modules/web_infrastructure/supervisorctl.py @@ -183,14 +183,14 @@ def main(): if module.check_mode: module.exit_json(changed=True) for process_name in to_take_action_on: - rc, out, err = run_supervisorctl(action, process_name) + rc, out, err = run_supervisorctl(action, process_name, check_rc=True) if '%s: %s' % (process_name, expected_result) not in out: module.fail_json(msg=out) module.exit_json(changed=True, name=name, state=state, affected=to_take_action_on) if state == 'restarted': - rc, out, err = run_supervisorctl('update') + rc, out, err = run_supervisorctl('update', check_rc=True) processes = get_matched_processes() take_action_on_processes(processes, lambda s: True, 'restart', 'started')