-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Fix Ansible 12 double-templating and Jinja2 spacing issues #14836
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This PR fixes critical deployment issues and improves code consistency for Ansible 12 compatibility. ## Fixed Issues ### 1. Double-templating bug (Issue #14835) Fixed 7 instances of invalid double-templating that breaks deployments: - Changed `{{ lookup('file', '{{ var }}') }}` to `{{ lookup('file', var) }}` - Affects Azure, DigitalOcean, GCE, Linode, and IPsec configurations - Added comprehensive test to prevent regression ### 2. Jinja2 spacing inconsistencies Fixed 33+ spacing issues for better code quality: - Removed spaces between Jinja2 blocks: `}} {%` → `}}{%` - Fixed operator spacing: `int -1` → `int - 1` - Fixed filter spacing: `|b64encode` → `| b64encode` - Consolidated multiline expressions to single lines ### 3. Test suite improvements Enhanced boolean type checking test to be more targeted: - Excludes external dependencies and CloudFormation templates - Only tests Algo's actual codebase - Verified with mutation testing - Added comprehensive documentation ## Testing - All 87 unit tests pass - 0 Jinja2 spacing issues remaining (verified by ansible-lint) - Ansible syntax checks pass for all playbooks - Mutation testing confirms tests catch real issues 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Claude finished @dguido's task —— View job PR Review - Comprehensive AnalysisI've thoroughly reviewed this PR and am impressed with the quality and comprehensiveness of the fixes. This addresses critical deployment failures caused by Ansible 12's stricter template validation. ✅ Excellent Work - Strong ApproveDouble-Templating Fixes (Critical Bug Fixes)
These fixes resolve the core Ansible 12 deployment failures without changing functionality. Jinja2 Spacing Corrections
Test Suite EnhancementsNew
Enhanced
Security Analysis ✅No security concerns identified:
Security improvements:
Performance Considerations ✅Minimal performance impact:
Code Quality Assessment ✅Follows repository best practices:
Potential Issues
|
- Remove unnecessary f-string prefix where no placeholders are used - Fixes ruff F541 error
- Break long lines to stay within 120 character limit - Extract variables for better readability - Fixes ruff E501 errors
Summary
This PR fixes critical deployment failures caused by double-templating issues and improves code consistency by resolving all Jinja2 spacing issues throughout the codebase.
Problem
{{ lookup('file', '{{ var }}') }}
Solution
1. Fixed Double-Templating (Critical Bug Fix)
'{{ var }}'
→var
inside lookup() calls2. Fixed Jinja2 Spacing Issues
}} {%
→}}{%
(removed spaces between blocks)int -1
→int - 1
(proper operator spacing)|b64encode
→| b64encode
(filter spacing)- 1 ]['field']
→- 1]['field']
(array access)3. Enhanced Test Suite
test_comprehensive_boolean_scan.py
to only scan Algo code.env/
,ansible_collections/
)test_double_templating.py
to prevent regressionTesting
✅ All 87 unit tests pass
$ uv run pytest tests/unit/ ======================= 87 passed, 14 warnings in 4.08s ========================
✅ 0 Jinja2 spacing issues remaining
✅ Ansible syntax checks pass
✅ Mutation testing verified
false
in else clausesFiles Changed
Impact
Fixes #14835
Related
🤖 Generated with Claude Code
Co-Authored-By: Claude [email protected]