From d361f3b44ea06789d4611c413f73a2b4efa5aa77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Moser?= Date: Mon, 7 Mar 2016 07:35:04 +0100 Subject: [PATCH] proposal: re-run handlers --- docs/proposals/re-run-handlers.md | 77 +++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 docs/proposals/re-run-handlers.md diff --git a/docs/proposals/re-run-handlers.md b/docs/proposals/re-run-handlers.md new file mode 100644 index 0000000000..9b5a01df8f --- /dev/null +++ b/docs/proposals/re-run-handlers.md @@ -0,0 +1,77 @@ +# Proposal: Re-run handlers cli option + +*Author*: René Moser <@resmo> + +*Date*: 07/03/2016 + +- Status: New + +## Motivation + +The most annoying thing users face using ansible in production is running handlers manually after a task failed after a notified handler. + +### Problems + +Handler notifications get lost after a task failed and there is no help from ansible to catch up the notified handlers in a next ansible playbook run. + +~~~yaml +- hosts: localhost + gather_facts: no + tasks: + - name: simple task + shell: echo foo + notify: get msg out + + - name: this tasks fails + fail: msg="something went wrong" + + handlers: + - name: get msg out + shell: echo handler run +~~~ + +Result: + +~~~ +$ ansible-playbook test.yml + +PLAY *************************************************************************** + +TASK [simple task] ************************************************************* +changed: [localhost] + +TASK [this tasks fails] ******************************************************** +fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "something went wrong"} + +NO MORE HOSTS LEFT ************************************************************* + +RUNNING HANDLER [get msg out] ************************************************** + to retry, use: --limit @test.retry + +PLAY RECAP ********************************************************************* +localhost : ok=1 changed=1 unreachable=0 failed=1 +~~~ + +## Solution proposal + +Similar to retry, ansible should provide a way to manully invoke a list of handlers additionaly to the notified handlers in the plays: + +~~~ + $ ansible-playbook test.yml --notify-handlers ,, + $ ansible-playbook test.yml --notify-handlers @test.handlers +~~~ + +Example: + +~~~ + $ ansible-playbook test.yml --notify-handlers "get msg out" +~~~ + +The stdout of a failed play should provide an example how to run notified handlers in the next run: + +~~~ +... +RUNNING HANDLER [get msg out] ************************************************** + to retry, use: --limit @test.retry --notify-handlers @test.handlers +~~~ +