ansible.builtin.fail – Fail with custom message
Note
This module is part of ansible-base
and included in all Ansible installations. In most cases, you can use the short module name fail even without specifying the collections:
keyword. Despite that, we recommend you use the FQCN for easy linking to the module documentation and to avoid conflicting with other collections that may have the same module name.
New in version 0.8: of ansible.builtin
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 | Choices/Defaults | Comments |
---|---|---|
msg string | Default: "Failed as requested from task" | The customized message used for failing execution. If omitted, fail will simply bail out with a generic message. |
Notes
Note
- This module is also supported for Windows targets.
See Also
See also
- ansible.builtin.assert
-
The official documentation on the ansible.builtin.assert module.
- ansible.builtin.debug
-
The official documentation on the ansible.builtin.debug module.
- ansible.builtin.meta
-
The official documentation on the ansible.builtin.meta module.
Examples
- name: Example using fail and when together fail: msg: The system may not be provisioned according to the CMDB status. when: cmdb_status != "to-be-staged"
Authors
- Dag Wieers (@dagwieers)
© 2012–2018 Michael DeHaan
© 2018–2021 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.11/collections/ansible/builtin/fail_module.html