Fix --force-handlers, and allow it in plays and ansible.cfg

The --force-handlers command line argument was not correctly running
handlers on hosts which had tasks that later failed. This corrects that,
and also allows you to specify force_handlers in ansible.cfg or in a
play.
This commit is contained in:
Jesse Rusak 2015-04-04 16:37:14 -04:00 committed by Jesse Rusak
commit 652cd6cd5e
11 changed files with 123 additions and 12 deletions

View file

@ -252,6 +252,20 @@ This options forces color mode even when running without a TTY::
force_color = 1
.. _force_handlers:
force_handlers
==============
.. versionadded:: 1.9.1
This option causes notified handlers to run on a host even if a failure occurs on that host::
force_handlers = True
The default is False, meaning that handlers will not run if a failure has occurred on a host.
This can also be set per play or on the command line. See :doc:`_handlers_and_failure` for more details.
.. _forks:
forks

View file

@ -29,6 +29,26 @@ write a task that looks like this::
Note that the above system only governs the failure of the particular task, so if you have an undefined
variable used, it will still raise an error that users will need to address.
.. _handlers_and_failure:
Handlers and Failure
````````````````````
.. versionadded:: 1.9.1
When a task fails on a host, handlers which were previously notified
will *not* be run on that host. This can lead to cases where an unrelated failure
can leave a host in an unexpected state. For example, a task could update
a configuration file and notify a handler to restart some service. If a
task later on in the same play fails, the service will not be restarted despite
the configuration change.
You can change this behavior with the ``--force-handlers`` command-line option,
or by including ``force_handlers: True`` in a play, or ``force_handlers = True``
in ansible.cfg. When handlers are forced, they will run when notified even
if a task fails on that host. (Note that certain errors could still prevent
the handler from running, such as a host becoming unreachable.)
.. _controlling_what_defines_failure:
Controlling What Defines Failure