Skip to content

Ansible v12.0.0 / ansible-core 2.19 causes error Conditionals must have a boolean result. #123

@bmccafferty

Description

@bmccafferty

Have you checked ReadtheDocs?:
Yes

Describe the Issue
Ansible v12.0.0 / ansible-core 2.19 causes error Conditionals must have a boolean result.

Expected Behavior
Run completes successfully

Actual Behavior
The run fails on latest ansible via pip from windows. If you pin to ansible==11.9.0 then runs will work successfully. Affecting all branches inc devel

14:08:40      amazon-ebs.windows-server-2019: TASK [Windows-2019-CIS : Main | Gather Distribution Info] **********************
14:08:40      amazon-ebs.windows-server-2019: skipping: [REDACTED.eu-west-2.compute.internal]
14:08:40      amazon-ebs.windows-server-2019:
14:08:40      amazon-ebs.windows-server-2019: TASK [Windows-2019-CIS : Main | Check OS Version And Family] *******************
14:08:40      amazon-ebs.windows-server-2019: [ERROR]: Task failed: Conditional result (True) was derived from value of type 'str' at '/home/jenkins/fargate-com-ce-single-agent-packer-jws2n/workspace/ami-bakery-windows-build/ansible/playbooks/roles/Windows-2019-CIS/tasks/main.yml:23:9'. Conditionals must have a boolean result.
14:08:40      amazon-ebs.windows-server-2019:
14:08:40      amazon-ebs.windows-server-2019: Task failed.
14:08:40      amazon-ebs.windows-server-2019: Origin: /home/jenkins/fargate-com-ce-single-agent-packer-jws2n/workspace/ami-bakery-windows-build/ansible/playbooks/roles/Windows-2019-CIS/tasks/main.yml:17:3
14:08:40      amazon-ebs.windows-server-2019:
14:08:40      amazon-ebs.windows-server-2019: 15     gather_subset: distribution,!all,!min
14:08:40      amazon-ebs.windows-server-2019: 16
14:08:40      amazon-ebs.windows-server-2019: 17 - name: Main | Check OS Version And Family
14:08:40      amazon-ebs.windows-server-2019:      ^ column 3
14:08:40      amazon-ebs.windows-server-2019:
14:08:40      amazon-ebs.windows-server-2019: <<< caused by >>>
14:08:40      amazon-ebs.windows-server-2019:
14:08:40      amazon-ebs.windows-server-2019: Conditional result (True) was derived from value of type 'str' at '/home/jenkins/fargate-com-ce-single-agent-packer-jws2n/workspace/ami-bakery-windows-build/ansible/playbooks/roles/Windows-2019-CIS/tasks/main.yml:23:9'. Conditionals must have a boolean result.
14:08:40      amazon-ebs.windows-server-2019: Origin: /home/jenkins/fargate-com-ce-single-agent-packer-jws2n/workspace/ami-bakery-windows-build/ansible/playbooks/roles/Windows-2019-CIS/tasks/main.yml:23:9
14:08:40      amazon-ebs.windows-server-2019:
14:08:40      amazon-ebs.windows-server-2019: 21     that:
14:08:40      amazon-ebs.windows-server-2019: 22       - ansible_os_family == 'Windows'
14:08:40      amazon-ebs.windows-server-2019: 23       - ansible_distribution | regex_search('(Microsoft Windows Server 2019)')
14:08:40      amazon-ebs.windows-server-2019:            ^ column 9
14:08:40      amazon-ebs.windows-server-2019:
14:08:40      amazon-ebs.windows-server-2019: Broken conditionals can be temporarily allowed with the `ALLOW_BROKEN_CONDITIONALS` configuration option.
14:08:40      amazon-ebs.windows-server-2019:
14:08:40      amazon-ebs.windows-server-2019: fatal: [REDACTED.eu-west-2.compute.internal]: FAILED! => {"changed": false, "msg": "Task failed: Conditional result (True) was derived from value of type 'str' at '/home/jenkins/fargate-com-ce-single-agent-packer-jws2n/workspace/ami-bakery-windows-build/ansible/playbooks/roles/Windows-2019-CIS/tasks/main.yml:23:9'. Conditionals must have a boolean result."}
14:08:40      amazon-ebs.windows-server-2019:
14:08:40      amazon-ebs.windows-server-2019: PLAY RECAP *********************************************************************
14:08:40      amazon-ebs.windows-server-2019: REDACTED.eu-west-2.compute.internal : ok=2    changed=0    unreachable=0    failed=1    skipped=1    rescued=0    ignored=0
14:08:40      amazon-ebs.windows-server-2019:

Control(s) Affected
What controls are being affected by the issue
ALL
Breaks are pre-checks part:
Check OS Version And Family

Environment (please complete the following information):

  • branch being used: [e.g. devel] - devel
  • Ansible Version: [e.g. 2.10] - 2.19
  • Host Python Version: [e.g. Python 3.7.6] - python 3.12.9
  • Ansible Server Python Version: [e.g. Python 3.7.6] - python 3.12.9
  • Additional Details: Affects 2022 as well. Will report seperatly

Additional Notes
Caused due to changes in ansible 2.19 as documented on official docs:
https://docs.ansible.com/ansible/latest/porting_guides/porting_guide_core_2.19.html#broken-conditionals

Possible Solution
Update code to be compatible with ansible 2.19 as per the porting guide:
https://docs.ansible.com/ansible/latest/porting_guides/porting_guide_core_2.19.html#broken-conditionals

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions