42 lines
No EOL
1.8 KiB
Markdown
42 lines
No EOL
1.8 KiB
Markdown
# ansible.builtin.assert
|
||
This module asserts that given expressions are true with an optional custom message
|
||
|
||
## Parameters
|
||
| Parameter | Type | Description |
|
||
| ----------- | --------------------------------- | ---------------------------------------------------------------------------------------- |
|
||
| **fail_msg** | string | The customized message used for a failing assertion |
|
||
| **quiet** | boolean | Set this to `true` to avoid verbose output |
|
||
| **success_msg** | string | The customized message used for a successful assertion |
|
||
| **that** | list / elements=string / required | A list of string expressions of the same form that can be passed to the ‘when’ statement |
|
||
|
||
## Examples
|
||
```yaml
|
||
- ansible.builtin.assert: { that: "ansible_os_family != 'RedHat'" }
|
||
|
||
- ansible.builtin.assert:
|
||
that:
|
||
- "'foo' in some_command_result.stdout"
|
||
- number_of_the_counting == 3
|
||
|
||
- name: After version 2.7 both 'msg' and 'fail_msg' can customize failing assertion message
|
||
ansible.builtin.assert:
|
||
that:
|
||
- my_param <= 100
|
||
- my_param >= 0
|
||
fail_msg: "'my_param' must be between 0 and 100"
|
||
success_msg: "'my_param' is between 0 and 100"
|
||
|
||
- name: Please use 'msg' when ansible version is smaller than 2.7
|
||
ansible.builtin.assert:
|
||
that:
|
||
- my_param <= 100
|
||
- my_param >= 0
|
||
msg: "'my_param' must be between 0 and 100"
|
||
|
||
- name: Use quiet to avoid verbose output
|
||
ansible.builtin.assert:
|
||
that:
|
||
- my_param <= 100
|
||
- my_param >= 0
|
||
quiet: true
|
||
``` |