Skip to content

capable.core219.evaluate

Evaluate Ansible conditional expressions.

Requires ansible-core >=2.19.1; version 2.19.0 can expose runtime conditional values despite task no_log.

Evaluates trusted expressions using the native core conditional API, like when.

Shares term semantics with the capable.core219.evaluate lookup plugin.

Expressions must be trusted strings defined in YAML, not string literals inside Jinja expressions.

External data from files, commands, lookups, and remote results is never promoted to executable code.

Each positional list is expanded once. All reached terms must be boolean or trusted strings and must pass.

Evaluation short-circuits on false. An explicit empty list returns true; an empty string is an error.

Uses variables visible in the Jinja context, including task variables and Jinja set variables.

Jinja for-loop locals are not included in that context; use Ansible task loops instead.

The filter creates an independent public loader with role/task search paths; it cannot inherit caller Vault secrets or loader-specific state.

For expressions containing lookups that require Vault credentials or caller loader state, use the capable.core219.evaluate lookup instead.

Expressions must not contain template delimiters. Native core conditional configuration applies.

This never-shipped feature moved from capable.core212.evaluate to capable.core219.evaluate.

Type: raw · Required: yes

A trusted YAML conditional expression, boolean, or list of these. Supports the same syntax as when and failed_when.


Type: raw

Additional positional expressions or lists; all must pass together with _input. May be repeated positionally; keyword arguments are not supported.


- name: Evaluate a single conditional expression
vars:
ready: true
ready_condition: ready is defined and ready
is_ready: "{{ ready_condition | capable.core219.evaluate }}"
ansible.builtin.assert:
that:
- is_ready is sameas true
- name: Evaluate multiple conditional expressions (all must pass)
vars:
foo: 1
bar: 2
foo_condition: foo == 1
bar_condition: bar == 2
is_configured: "{{ foo_condition | capable.core219.evaluate(bar_condition) }}"
ansible.builtin.assert:
that:
- is_configured is sameas true
- name: Evaluate a list of conditional expressions
vars:
conditions:
- foo == 1
- bar == 2
foo: 1
bar: 2
is_configured: "{{ conditions | capable.core219.evaluate }}"
ansible.builtin.assert:
that:
- is_configured is sameas true

Type: bool

Boolean AND of the conditional results.


  • Kirill Satarin (@kksat)