Skip to content

'Adding primary group' task fails to evaluate condition in later Ansible version #59

@fidanf

Description

@fidanf

Env

ansible [core 2.19.0]
  python version = 3.12.11 (main, Jul  2 2025, 11:18:53)
  jinja version = 3.1.6
  pyyaml version = 6.0.2 (with libyaml v0.2.5)

Error output

[ERROR]: Task failed: Conditional result was '' of type 'str', which evaluates to False. Conditionals must have a boolean result.

Task failed.
Origin: .ansible/roles/weareinteractive.users/tasks/manage.yml:3:3

1 ---
2
3 - name: Adding primary group
    ^ column 3

<<< caused by >>>

Conditional result was '' of type 'str', which evaluates to False. Conditionals must have a boolean result.
Origin: .ansible/roles/weareinteractive.users/tasks/manage.yml:7:9

5     name: "{{ users_group }}"
6     state: present
7   when: users_group is defined and users_group
          ^ column 9

Broken conditionals can be temporarily allowed with the `ALLOW_BROKEN_CONDITIONALS` configuration option.

fatal: [runner01]: FAILED! => {"changed": false, "msg": "Task failed: Conditional result was '' of type 'str', which evaluates to False. Conditionals must have a boolean result."}

Suggested solution

  1. Set an empty string in defaults/main.yml file to indicate the expected type and also provide a default value
  2. Fix conditional to allow users to skip the task if unwilling to set a primary group

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