ansible.builtin.fail module – Fail with custom message
Note
This module is part of ansible-core
and included in all Ansible
installations. In most cases, you can use the short
module name
fail
even without specifying the collections keyword.
However, we recommend you use the Fully Qualified Collection Name (FQCN) ansible.builtin.fail
for easy linking to the
module documentation and to avoid conflicting with other collections that may have
the same module name.
Synopsis
This module fails the progress with a custom message.
It can be useful for bailing out when a certain condition is met using
when
.This module is also supported for Windows targets.
Note
This module has a corresponding action plugin.
Parameters
Parameter |
Comments |
---|---|
The customized message used for failing execution. If omitted, fail will simply bail out with a generic message. Default: |
Attributes
Attribute |
Support |
Description |
---|---|---|
Support: full |
Indicates this has a corresponding action plugin so some parts of the options can be executed on the controller |
|
Support: none |
Supports being used with the |
|
Support: none |
Is usable alongside become keywords |
|
Support: none |
Forces a ‘global’ task that does not execute per host, this bypasses per host templating and serial, throttle and other loop considerations Conditionals will work as if This action will not work normally outside of lockstep strategies |
|
Support: full |
Can run in check_mode and return changed status prediction without modifying target, if not supported the action will be skipped. |
|
Support: none |
Uses the target’s configured connection information to execute code on it |
|
Support: partial Aside from |
Can be used in conjunction with delegate_to and related keywords |
|
Support: none |
Will return details on what has changed (or possibly needs changing in check_mode), when in diff mode |
|
Platforms: all |
Target OS/families that can be operated against |
See Also
See also
- ansible.builtin.assert
Asserts given expressions are true.
- ansible.builtin.debug
Print statements during execution.
- ansible.builtin.meta
Execute Ansible ‘actions’.
Examples
- name: Example using fail and when together
ansible.builtin.fail:
msg: The system may not be provisioned according to the CMDB status.
when: cmdb_status != "to-be-staged"