This commit is contained in:
JMARyA 2023-12-04 11:02:23 +01:00
commit c5cd492449
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
475 changed files with 27928 additions and 0 deletions

View file

@ -0,0 +1,42 @@
# 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
```