Skip to main content

Note

This module is part of ansible-base and included in all Ansible installations. In most cases, you can use the short module name assert even without specifying the collections: keyword. Despite that, we recommend you use the FQCN for easy linking to the module documentation and to avoid conflicting with other collections that may have the same module name.

New in version 1.5: of ansible.builtin

Synopsis

  • This module asserts that given expressions are true with an optional custom message.
  • This module is also supported for Windows targets.

Parameters

Parameter Choices/Defaults Comments
fail_msg
string
added in 2.7 of ansible.builtin
The customized message used for a failing assertion.
This argument was called 'msg' before Ansible 2.7, now it is renamed to 'fail_msg' with alias 'msg'.

aliases: msg
quiet
boolean
added in 2.8 of ansible.builtin
    Choices:
  • no
  • yes
Set this to yes to avoid verbose output.
success_msg
string
added in 2.7 of ansible.builtin
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.

Notes

Note

  • This module is also supported for Windows targets.

See Also

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 

Authors

  • Ansible Core Team
  • Michael DeHaan

Comments

Popular posts from this blog

Are Regular VACUUM ANALYZE Still Recommended Under 9.1?

Can Feynman Diagrams Be Used To Represent Any Perturbation Theory?