ansible.builtin.assert (v2.4.4.0-1) — module

Asserts given expressions are true

| "added in version" 1.5 of ansible.builtin"

Authors: Ansible Core Team, Michael DeHaan

stableinterface | supported by core

Install Ansible via pip

Install with pip install ansible==2.4.4.0.post1

Description

This module asserts that given expressions are true with an optional custom message.

This module is also supported for Windows targets.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- assert: { that: "ansible_os_family != 'RedHat'" }
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- assert:
    that:
      - "'foo' in some_command_result.stdout"
      - "number_of_the_counting == 3"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- assert:
    that:
      - "my_param <= 100"
      - "my_param >= 0"
    msg: "'my_param' must be between 0 and 100"

Inputs

    
msg:
    description:
    - The customized message used for a failing assertion

that:
    description:
    - A string expression of the same form that can be passed to the 'when' statement
    - Alternatively, a list of string expressions
    required: true