capable.core219.predicate
Build callable predicate function from Python lambda expression.
Parameters
Section titled “Parameters”_input (required)
Section titled “_input (required)”Type: str · Required: yes
Python lambda expression string.
Example lambda x: x % 2 == 0
on_error
Section titled “on_error”Type: str · Default: false · Choices: false | fail
Controls behavior when predicate execution fails or does not return bool.
false, given as string or boolean, returns False for that predicate call.
fail raises plugin error.
Examples
Section titled “Examples”- name: Build callable predicate from expression vars: is_even: "{{ 'lambda x: x % 2 == 0' | capable.core219.predicate }}" ansible.builtin.assert: that: - is_even(4) is sameas true - is_even(5) is sameas false
- name: Return false on predicate failure by default vars: nonzero: "{{ 'lambda x: 1 / x > 0' | capable.core219.predicate }}" ansible.builtin.assert: that: - nonzero(0) is sameas falseReturn Values
Section titled “Return Values”Type: raw
Callable predicate function object.
Authors
Section titled “Authors”- Kirill Satarin (@kksat)