Skip to content

Invalid conditional #230

@lldelisle

Description

@lldelisle

Dear developers of the ansible role,
Thank you so much this is super useful. When I installed a new galaxy, I got an issue with:

when: item | default(False)

The error was:

TASK [galaxyproject.galaxy : Create additional privilege separated directories] *******************************************************************
[ERROR]: Task failed: Conditional result was '/opt/galaxy/galaxy_root/venv' of type 'str', which evaluates to True. Conditionals must have a boolean result.

Task failed.
Origin: XXX/roles/galaxyproject.galaxy/tasks/paths.yml:16:7

14       when: galaxy_root is defined
15
16     - name: Create additional privilege separated directories
         ^ column 7

<<< caused by >>>

Conditional result was '/opt/galaxy/galaxy_root/venv' of type 'str', which evaluates to True. Conditionals must have a boolean result.
Origin: XXX/roles/galaxyproject.galaxy/tasks/paths.yml:24:13

22         mode: "{{ __galaxy_dir_perms }}"
23       loop: "{{ galaxy_privsep_dirs + galaxy_extra_privsep_dirs }}"
24       when: item | default(False)
               ^ column 13

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

failed: [myhost] (item=/opt/galaxy/galaxy_root/venv) => changed=false 
  ansible_loop_var: item
  item: /opt/galaxy/galaxy_root/venv
  msg: 'Task failed: Conditional result was ''/opt/galaxy/galaxy_root/venv'' of type ''str'', which evaluates to True. Conditionals must have a boolean result.'
[ERROR]: Task failed: Conditional result was '/opt/galaxy/galaxy_root/server' of type 'str', which evaluates to True. Conditionals must have a boolean result.

etc..

I fixed it by adding to my ansible.cfg (in the default section):

allow_broken_conditionals = yes

Here is my version of ansible:

[delislel@HPdelislel ~]$ ansible --version
ansible [core 2.19.0]
  config file = None
  configured module search path = ['/home/delislel/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.13/site-packages/ansible
  ansible collection location = /home/delislel/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.13.5 (main, Jun 21 2025, 09:35:00) [GCC 15.1.1 20250425] (/usr/bin/python)
  jinja version = 3.1.6
  pyyaml version = 6.0.2 (with libyaml v0.2.5)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions