assert – Asserts given expressions are true¶
Synopsis¶
- This module asserts that given expressions are true with an optional custom message.
- This module is also supported for Windows targets.
Parameters¶
See Also¶
See also
- debug – Print statements during execution
- The official documentation on the debug module.
- fail – Fail with custom message
- The official documentation on the fail module.
- meta – Execute Ansible ‘actions’
- The official documentation on the meta module.
Examples¶
- assert: { that: "ansible_os_family != 'RedHat'" }
- 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
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
assert:
that:
- my_param <= 100
- my_param >= 0
msg: "'my_param' must be between 0 and 100"
- name: use quiet to avoid verbose output
assert:
that:
- my_param <= 100
- my_param >= 0
quiet: true
Status¶
- This module is guaranteed to have backward compatible interface changes going forward. [stableinterface]
- This module is maintained by the Ansible Core Team. [core]
Red Hat Support¶
More information about Red Hat’s support of this module is available from this Red Hat Knowledge Base article.
Authors¶
- Ansible Core Team
- Michael DeHaan
Hint
If you notice any issues in this documentation, you can edit this document to improve it.