Skip to content

Conditional errors with Ansible 2.19 #511

@agross

Description

@agross

Description

Ansible 12 (or 2.19) changed conditionals to require yielding boolean results.

To reproduce

Apply the role with systemd timers.

Current behavior

TASK [hifis.unattended_upgrades : Deploy apt-daily timer] ************************************************************************************* 17:06:57
[ERROR]: Task failed: Conditional result (True) was derived from value of type 'dict' at '/Users/agross/.ansible/roles/hifis.unattended_upgrades/tasks/systemd_timers.yml:44:7'. Conditionals must have a boolean result.

Task failed.
Origin: /Users/agross/.ansible/roles/hifis.unattended_upgrades/tasks/systemd_timers.yml:35:3

33   register: '_apt_daily_upgrade_timer_d'
34
35 - name: 'Deploy apt-daily timer'
     ^ column 3

<<< caused by >>>

Conditional result (True) was derived from value of type 'dict' at '/Users/agross/.ansible/roles/hifis.unattended_upgrades/tasks/systemd_timers.yml:44:7'. Conditionals must have a boolean result.
Origin: /Users/agross/.ansible/roles/hifis.unattended_upgrades/tasks/systemd_timers.yml:44:7

42   when:
43     - '_apt_daily.rc == 0'
44     - '_apt_daily_timer_d' # skip if run for the first time in check mode
         ^ column 7

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

fatal: [nest]: FAILED! =>
    changed: false
    msg: 'Task failed: Conditional result (True) was derived from value of type ''dict''
        at ''/Users/agross/.ansible/roles/hifis.unattended_upgrades/tasks/systemd_timers.yml:44:7''.
        Conditionals must have a boolean result.'

Expected behavior

The _apt_daily_timer_d test should yield boolean, not truthy.

OS / Environment

Doesn’t matter in this case, but I have a Mac.

Ansible version

$ ansible --version
ansible [core 2.19.3]
  config file = /Users/agross/lab/ansible-home-network/ansible.cfg
  configured module search path = ['/Users/agross/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /opt/homebrew/Cellar/ansible/12.1.0/libexec/lib/python3.13/site-packages/ansible
  ansible collection location = /Users/agross/.ansible/collections:/usr/share/ansible/collections
  executable location = /opt/homebrew/bin/ansible
  python version = 3.13.9 (main, Oct 14 2025, 13:52:31) [Clang 17.0.0 (clang-1700.3.19.1)] (/opt/homebrew/Cellar/ansible/12.1.0/libexec/bin/python)
  jinja version = 3.1.6
  pyyaml version = 6.0.3 (with libyaml v0.2.5)

Collection version

v3.2.1

Additional context

https://docs.ansible.com/ansible/devel/porting_guides/porting_guide_12.html#broken-conditionals

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions