capable.core219.predicate
Evaluate value with Python lambda predicate expression.
Positional and keyword arguments after O(expression), except O(on_error), are passed to the predicate after the tested value. For example 5 is capable.core219.predicate('lambda x, low, high: low <= x <= high', 1, 10) calls the predicate as predicate(5, 1, 10).
Parameters
Section titled “Parameters”_input (required)
Section titled “_input (required)”Type: raw · Required: yes
Value passed as first predicate argument.
expression (required)
Section titled “expression (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.
fail raises plugin error.
Must be passed as keyword argument; extra positional arguments are passed to the predicate.
Examples
Section titled “Examples”- name: Evaluate predicate test ansible.builtin.assert: that: - 4 is capable.core219.predicate('lambda x: x % 2 == 0') - 5 is not capable.core219.predicate('lambda x: x % 2 == 0')
- name: Fail through on predicate failure ansible.builtin.assert: that: - 0 is capable.core219.predicate('lambda x: 1 / x > 0', on_error='fail')Return Values
Section titled “Return Values”Type: bool
Predicate evaluation result.
Authors
Section titled “Authors”- Kirill Satarin (@kksat)