capable.core212.logical
Validate whether a data structure is a well-formed logical expression.
Tests whether a given value is a valid logical conditional structure that the logical filter can evaluate.
Returns true if the value is a dict containing a valid if/then/else block or a valid logical operator (and, or, xor, not).
Conditions must be booleans, string booleans (“true”, “false”, “yes”, “no”), or nested logical dicts.
Parameters
Section titled “Parameters”value (required)
Section titled “value (required)”Type: raw · Required: yes
The value to test for validity as a logical expression.
Examples
Section titled “Examples”# Simple if/then/else- name: Check if a dict is a valid logical expression ansible.builtin.assert: that: - simple_if is capable.core212.logical vars: simple_if: if: true then: value else: other
# if/then/elseif/else- name: Validate elseif chain ansible.builtin.assert: that: - data is capable.core212.logical vars: data: if: false then: first elseif: - elseif: true then: second else: last
# Logical operators- name: Validate and operator ansible.builtin.assert: that: - data is capable.core212.logical vars: data: and: - true - true
- name: Validate not operator ansible.builtin.assert: that: - data is capable.core212.logical vars: data: not: true
# Negative test - plain dict is not logical- name: Regular dict is not a logical expression ansible.builtin.assert: that: - data is not capable.core212.logical vars: data: name: server1 port: 8080
# Negative test - invalid condition type- name: Non-boolean condition is invalid ansible.builtin.assert: that: - data is not capable.core212.logical vars: data: if: 42 then: valueReturn Values
Section titled “Return Values”logical
Section titled “logical”Type: boolean
Whether the value is a valid logical expression.
Authors
Section titled “Authors”- Todd Lewis <todd_lewis@unc.edu>
- Kirill Satarin (@kksat)