Skip to content

default_web inventory variable must be boolean (Ansible 2.20+ strictness causes failure) #9

@mlazzarotto

Description

@mlazzarotto

Summary

When running this playbook with Ansible v2.20.4+, the playbook fails if the default_web variable in the inventory is set as an integer (e.g., 1) instead of a boolean (true/false).

Error Output

[ERROR]: Task failed: Conditional result (True) was derived from value of type 'int' at '/Users/marco/Documents/ansible/workshop-docker/kasm/inventory:98:18'. Conditionals must have a boolean result.

The error originates from:

  • /roles/install_common/tasks/main.yml (around lines 18–22)
  • When default_web is set to 1, the following breaks:
    - set_fact:
        web_ip: ...
        target_ip: ...
      when: default_web
    Ansible 2.20 now enforces that when: conditions must be boolean strictly, so 1 (int) is not accepted.

Steps to Reproduce

  1. Set default_web: 1 in your inventory file.
  2. Run the playbook with Ansible 2.20.4 or later.
  3. Observe failure on tasks that use when: default_web.

Solution

Update the inventory to use boolean syntax instead of integer:

default_web: true

Or if you do not wish to stick to a default, use:

default_web: false

Consider clarifying in docs/README that this field must now be a boolean, not int.

Environment

  • Ansible version: 2.20.4
  • kasmtech/ansible: latest
  • OS: Any

Additional Context

This is due to new strictness in Ansible 2.20+ regarding conditionals and types.


Suggested fix:

  • Update docs to indicate boolean required.
  • Potentially coerce or cast default_web in playbook for backwards compatibility (e.g., when: default_web | bool).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions