ansible.builtin.bool filter – cast into a boolean
Note
This filter plugin is part of ansible-core
and included in all Ansible
installations. In most cases, you can use the short
plugin name
bool
.
However, we recommend you use the Fully Qualified Collection Name (FQCN) ansible.builtin.bool
for easy linking to the
plugin documentation and to avoid conflicting with other collections that may have
the same filter plugin name.
Synopsis
Attempt to cast the input into a boolean (
True
orFalse
) value.
Aliases: formerly_core_filter, formerly_core_masked_filter
Input
This describes the input of the filter, the value before | ansible.builtin.bool
.
Parameter |
Comments |
---|---|
Data to cast. |
Examples
# in vars
vars:
isbool: "{{ (a == b) | bool }} "
otherbool: "{{ anothervar | bool }} "
# in a task
...
when: some_string_value | bool
Return Value
Key |
Description |
---|---|
The boolean resulting of casting the input expression into a Returned: success |
Hint
Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up.