I have a play where I make edits to apache configs which includes a notify “restart apache”. That all works well, except in the following scenario:
Task A changes apache configs. Task B runs after task A fails and the play aborts. Apache still runs the old version of the config file.
I re-run the playbook, now task A skips since there’s nothing to change and Apache does not get restarted. The play finishes successfully but Apache never got restarted.
One path to go is to immediately restart apache, but that would lead to multiple restarts per run. Any ideas?
name: task that may fail [B]
command: this_may_fail
On this first run apache gets reconfigured, task B fails so apache doesn’t get restarted. On the second run, the first task is skipped, task B completes successfully, and apache does not get restarted and ends up running the original configuration.
I wonder if ansible's retry feature could be made smart enough to note the
handlers that were notified but not executed. Then on the subsequent run,
those handlers would get executed.