mandatory¶
Collection Note
This module is part of the ansible.builtin collection. To install the collection, use:
Added in versionhistorical.
Synopsis¶
- Depending on context undefined variables can be ignored or skipped, this ensures they force an error.
Parameters¶
| Parameter | Defaults / Choices | Comments |
|---|---|---|
| _input raw required |
Mandatory expression. | |
| msg str |
The customized message that is printed when the given variable is not defined. |
Examples¶
# results in a Filter Error
{{ notdefined | mandatory }}
# print a custom error message
{{ notdefined | mandatory(msg='This variable is required.') }}
Return Values¶
| Key | Data Type | Description | Returned |
|---|---|---|---|
| _value | raw | The input if defined, otherwise an error. |