Skip to content

Fix jinja2 error from newer ansible versions#16356

Merged
AlanCoding merged 3 commits intoansible:develfrom
AlanCoding:fix_checks
Mar 17, 2026
Merged

Fix jinja2 error from newer ansible versions#16356
AlanCoding merged 3 commits intoansible:develfrom
AlanCoding:fix_checks

Conversation

@AlanCoding
Copy link
Member

@AlanCoding AlanCoding commented Mar 17, 2026

SUMMARY

Attempts to fix failure

E         Conditional result (False) was derived from value of type 'list' at '/runner/project/project_update.yml:230:23'. Conditionals must have a boolean result.
E         Origin: /runner/project/project_update.yml:239:15
E         
E         237           when:
E         238             - roles_enabled | bool
E         239             - req_file
E                           ^ column 15
E         
E         Broken conditionals can be temporarily allowed with the `ALLOW_BROKEN_CONDITIONALS` configuration option.
E         
E         fatal: [localhost]: FAILED! => {"changed": false, "msg": "Task failed: Conditional result (False) was derived from value of type 'list' at '/runner/project/project_update.yml:230:23'. Conditionals must have a boolean result."}
ISSUE TYPE
  • Bug, Docs Fix or other nominal change
COMPONENT NAME
  • API

Note

Low Risk
Low risk change that only tightens Ansible when conditions to skip galaxy installs when no requirements file is found, preventing failures on newer Ansible versions.

Overview
Prevents project updates from failing on newer Ansible by changing the galaxy install tasks in project_update.yml to only run when a requirements file is actually found.

The when clauses now explicitly check req_file | length > 0 for role, collection, and combined installs, avoiding non-boolean conditional evaluation errors when first_found returns an empty value.

Written by Cursor Bugbot for commit 88d35d3. This will update automatically on new commits. Configure here.

Summary by CodeRabbit

  • Bug Fixes

    • Improved Galaxy installation process to only execute when valid requirements files are present, preventing errors during project updates.
  • Chores

    • Enhanced Ansible task caching behavior for improved execution performance.

@coderabbitai
Copy link

coderabbitai bot commented Mar 17, 2026

📝 Walkthrough

Walkthrough

This PR introduces two minor modifications: enabling caching for a facts-gathering task in test data by adding a cacheable: true argument, and tightening conditional checks in Galaxy installation tasks to verify that requirements files contain content before attempting installation.

Changes

Cohort / File(s) Summary
Facts Gathering Task
awx/main/tests/data/projects/facts/gather.yml
Adds args: block with cacheable: true to the set_fact task to enable fact caching.
Galaxy Installation Task Conditions
awx/playbooks/project_update.yml
Updates three conditional checks in role, collection, and combined requirements installation tasks from req_file presence check to req_file | length > 0, ensuring only non-empty requirements files trigger task execution.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Fix jinja2 error from newer ansible versions' is partially related to the changeset. While the PR addresses newer Ansible version compatibility issues (conditional semantics), the changes focus on fixing conditional logic in playbooks and adding fact caching, not specifically 'jinja2 errors' as the title suggests. Consider revising the title to be more specific: 'Fix Ansible conditional logic and fact caching for newer ansible-core versions' would better reflect the actual changes in both the playbook conditionals and the set_fact task configuration.
✅ Passed checks (2 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@AlanCoding
Copy link
Member Author

still failing dev-env

FAILED tests/test_ansible_facts.py::test_basic_ansible_facts - assert {}
FAILED tests/test_ansible_facts.py::test_slicing_with_facts - assert {}
FAILED tests/test_concurrent_fact_cache.py::test_concurrent_limit_does_not_clear_facts
FAILED tests/test_concurrent_fact_cache.py::test_concurrent_limit_does_not_revert_facts
FAILED tests/test_concurrent_fact_cache.py::test_fact_cache_scoped_to_inventory
FAILED tests/test_concurrent_fact_cache.py::test_constructed_inventory_facts_saved_to_source_host

a lot of facts related errors

@AlanCoding
Copy link
Member Author

versions

2026-03-17T12:01:06.7766575Z ##[group]Run python -m pip install --upgrade ansible-core
2026-03-17T12:01:06.7767074Z �[36;1mpython -m pip install --upgrade ansible-core�[0m
2026-03-17T12:01:06.7843859Z shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
2026-03-17T12:01:06.7844202Z env:
2026-03-17T12:01:06.7844397Z   LC_ALL: C.UTF-8
2026-03-17T12:01:06.7844901Z   CI_GITHUB_TOKEN: ***
2026-03-17T12:01:06.7845111Z   DEV_DOCKER_OWNER: ansible
2026-03-17T12:01:06.7845320Z   COMPOSE_TAG: devel
2026-03-17T12:01:06.7845514Z   UPSTREAM_REPOSITORY_ID: 91594105
2026-03-17T12:01:06.7845744Z   py_version: 3.13
2026-03-17T12:01:06.7845989Z   pythonLocation: /opt/hostedtoolcache/Python/3.13.12/x64
2026-03-17T12:01:06.7846410Z   PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.13.12/x64/lib/pkgconfig
2026-03-17T12:01:06.7846811Z   Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.13.12/x64
2026-03-17T12:01:06.7847155Z   Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.13.12/x64
2026-03-17T12:01:06.7847522Z   Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.13.12/x64
2026-03-17T12:01:06.7847870Z   LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.13.12/x64/lib
2026-03-17T12:01:06.7848182Z   OWNER_LC: ansible
2026-03-17T12:01:06.7848400Z   SSH_AUTH_SOCK: /tmp/ssh-O3LwEFReVTEQ/agent.2352
2026-03-17T12:01:06.7848656Z   SSH_AGENT_PID: 2353
2026-03-17T12:01:06.7849011Z ##[endgroup]
2026-03-17T12:01:08.7584060Z Collecting ansible-core
2026-03-17T12:01:08.8665410Z   Downloading ansible_core-2.20.3-py3-none-any.whl.metadata (7.7 kB)
2026-03-17T12:01:08.9024368Z Collecting jinja2>=3.1.0 (from ansible-core)
2026-03-17T12:01:08.9224560Z   Downloading jinja2-3.1.6-py3-none-any.whl.metadata (2.9 kB)
2026-03-17T12:01:08.9872686Z Collecting PyYAML>=5.1 (from ansible-core)
2026-03-17T12:01:09.0065662Z   Downloading pyyaml-6.0.3-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.metadata (2.4 kB)

2.20.3 is still maybe a month old...

@AlanCoding
Copy link
Member Author

Confirmed this is due to ansible-core version

  • working: ansible-core 2.15.13
  • not working: ansible-core 2.20.3

but this is difficult to change, due to being in the awx-ee

Here we go, this is the change ansible/awx-ee#271 @adrisala

@AlanCoding AlanCoding marked this pull request as ready for review March 17, 2026 13:15
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

b:
- "c"
- "d"
args:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing cacheable fix in gather_slow.yml causes test failures

Medium Severity

The cacheable: true parameter was moved under args: in gather.yml to fix compatibility with newer Ansible versions, but the identical file gather_slow.yml still has cacheable: true nested directly under set_fact:. gather_slow.yml is used by the concurrent fact cache tests (test_concurrent_limit_does_not_clear_facts, test_concurrent_limit_does_not_revert_facts), which are among the tests reported as still failing. The same args: fix needs to be applied there as well.

Fix in Cursor Fix in Web

@AlanCoding AlanCoding changed the title Fix error from newer ansible versions Fix jinja2 error from newer ansible versions Mar 17, 2026
Copy link
Member

@fosterseth fosterseth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ty

@AlanCoding
Copy link
Member Author

The awx-ee pushed a new image that should have ansible-core 2.18.z

However, this isn't out-of-date technically. So I just restarted the dev-env check, which should pick up the updated awx-ee, because I think that just comes from a ghcr pull (from inside the container). On that theory, I restarted and we will see.

@AlanCoding
Copy link
Member Author

Well shoot, same tests were still failing. pulled latest and confirming version:

$ podman run -it --rm quay.io/ansible/awx-ee:latest /bin/bash
bash-5.1$ ansible --version
ansible [core 2.18.14]

Will try one more time here.

@sonarqubecloud
Copy link

@AlanCoding AlanCoding merged commit 1646694 into ansible:devel Mar 17, 2026
33 of 34 checks passed
TheDevCodingKen pushed a commit to TheDevCodingKen/awx that referenced this pull request Mar 17, 2026
* Fix error from newer ansible versions

* Include fix for setting cachable

* Revert "Include fix for setting cachable"

This reverts commit 477293c.

Signed-off-by: TheDevCodingKen <93670654+TheDevCodingKen@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants