Skip to content

bool

Collection Note

This module is part of the ansible.builtin collection. To install the collection, use:

ansible-galaxy collection install ansible.builtin
Added in version historical.

Synopsis

  • Attempt to convert the input value into a boolean (V(True) or V(False)) from a common set of well-known values.
  • Valid true values are (V(True), 'yes', 'on', '1', 'true', 1).
  • Valid false values are (V(False), 'no', 'off', '0', 'false', 0).
  • A deprecation warning will result if an invalid value is supplied.
  • For more permissive boolean conversion, consider the P(ansible.builtin.truthy#test) or P(ansible.builtin.falsy#test) tests.
  • String comparisons are case-insensitive.

Parameters

Parameter Defaults / Choices Comments
_input
raw
required
Data to convert.

Examples

# in vars
vars:
  isbool: "{{ (a == b) | bool }} "
  otherbool: "{{ anothervar | bool }} "

# in a task
...
when: some_string_value | bool

Return Values

Key Data Type Description Returned
_value bool The boolean result of coercing the input expression to a V(True) or V(False) value.