Fix AIP boolean assertion for Ansible 12 jinja2_native mode#14950
Fix AIP boolean assertion for Ansible 12 jinja2_native mode#14950
Conversation
The ansible.utils.ipv4 filter returns the IP string when valid, not a boolean. Ansible 12+ enables jinja2_native by default, which requires assert.that clauses to evaluate to actual booleans. Add | bool filter to convert the truthy string to a proper boolean. Fixes #14948 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Code ReviewSummaryThis PR correctly fixes the Ansible 12+ jinja2_native mode compatibility issue in the AIP (Alternative Ingress IP) task. The change is minimal, targeted, and aligns with the project's documented best practices. Positive Aspects✅ Correct Fix for jinja2_native Mode: The addition of
✅ Minimal Change: Single line modification that solves exactly the issue reported in #14948 without introducing side effects. ✅ Quality Gates Passed: The PR description confirms all mandatory checks passed:
✅ Proper Parenthesization: Uses Technical AnalysisThe fix addresses the core issue: Filter Behavior:
ConsiderationsTest Coverage: The only usage of Documentation: The error message is clear and actionable: "The SNAT IPv4 address not found. Cannot proceed with the alternative ingress ip." RecommendationApprove and merge. This is a clean fix that follows project standards and solves a real compatibility issue blocking DigitalOcean deployments with Ansible 12+. Additional NotesVerified against CLAUDE.md section on Jinja2 Native Mode (lines 163-187), which explicitly covers this pattern. The fix is idiomatic and future-proof. |
|
Closing in favor of #14949 which uses the more correct approach: using the |
Summary
assert.thatclause in AIP task that fails with Ansible 12+ due tojinja2_nativemodeansible.utils.ipv4filter returns the IP string (not a boolean), which causes "Conditional result was derived from value of type 'str'" error| boolfilter to convert the truthy string to a proper booleanFixes #14948
Test plan
ansible-playbook main.yml --syntax-checkpassesansible-lint roles/common/tasks/aip/main.ymlpasses (0 failures, 0 warnings)pytest tests/unit/ -qpasses (91 tests)🤖 Generated with Claude Code