Documentation
PLEASE NOTE: This document applies to latest version and not to the latest stable release v2.19
Documentation for other releases can be found by using the version selector in the top right of any doc page.fail
Fail execution with a custom error message.
This module is useful for explicitly failing execution in conditional logic to provide meaningful error messages.
Attributes
check_mode:
support: none
Parameters
| Parameter | Required | Type | Values | Description |
|---|---|---|---|---|
| msg | string | The error message to display. |
Example
- name: Check for required config
stat:
path: /etc/app/required.conf
register: config_check
- name: Fail if config missing
fail:
msg: "Required configuration file /etc/app/required.conf not found"
when: not config_check.stat.exists
- name: Fail with templated message
fail:
msg: "Unsupported architecture: {{ rash.arch }}"