Fix Ansible 12.0.0 boolean type checking breaking deployments#14834
Fix Ansible 12.0.0 boolean type checking breaking deployments#14834
Conversation
Ansible 12.0.0 enforces strict type checking for conditionals and no longer
automatically converts string values "true"/"false" to booleans. This was
causing deployment failures after the recent Ansible version bump.
Changes:
- Fix ipv6_support to use 'is defined' which returns boolean instead of string
- Fix algo_* variables in input.yml to use {{ false }} instead of string "false"
- Add comprehensive tests to prevent regression
- Add mutation testing to verify tests catch the issue
The fix uses native boolean expressions instead of string literals, ensuring
compatibility with Ansible 12's strict type checking while maintaining backward
compatibility.
Fixes #14833
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
|
Claude finished @dguido's task —— View job 🔍 PR Review: Fix Ansible 12.0.0 Boolean Type CheckingReview SummaryThis is an excellent, well-crafted fix for a critical deployment-breaking issue. The changes are minimal, targeted, and backed by comprehensive testing using mutation testing principles. ✅ Code Quality & Best PracticesStrengths:
Technical correctness:
🧪 Test Coverage & Quality: Outstanding ⭐Test design philosophy:
Test quality highlights:
Evidence of thorough verification: # Mutation testing - verifies test catches the bug
bad_template = "{% if ... %}false{% endif %}"
result_bad = render_template(bad_template, vars_no_gateway)
assert result_bad == "false" # String literal
assert result != "false" # Our fix produces "False" (boolean)🔒 Security: No Concerns
⚡ Performance: Negligible Impact
🔄 Backwards Compatibility: ExcellentVerified compatibility:
🎯 Potential Issues & Edge CasesNone identified. This is a textbook example of a conservative, well-tested fix:
📊 Impact AssessmentCritical fix classification confirmed:
🚀 RecommendationAPPROVE & MERGE IMMEDIATELY This PR exemplifies:
The comprehensive test suite particularly stands out - it not only verifies the fix works but ensures the problem is detected if it reoccurs. 📋 Final Checklist
This is exactly the kind of fix Algo needs - conservative, well-tested, and addressing a critical issue affecting all users. |
- Fix import sorting and remove unused imports - Remove trailing whitespace and blank lines with whitespace - Use underscore prefix for unused loop variables - Remove unnecessary file open mode arguments - Add newlines at end of files - Remove unused variable assignments All ruff checks now pass.
Description
This PR fixes the critical deployment failure caused by Ansible 12.0.0's strict boolean type checking in conditionals. The recent Ansible version bump (11.9.0 → 12.0.0 in #14832) introduced breaking changes that prevent new deployments from completing.
Problem
Ansible 12.0.0 no longer automatically converts string values
"true"/"false"to booleans in conditionals, causing failures like:Solution
Replace string literal boolean values with native boolean expressions:
ipv6_support: Changed from{% if ... %}true{% else %}false{% endif %}to{{ ... is defined }}algo_*variables: Changed from{%- else %}false{% endif %}to{%- else %}{{ false }}{% endif %}Changes
ipv6_supportinroles/common/tasks/facts.ymlto return boolean instead of stringalgo_*variables ininput.ymlto use boolean{{ false }}instead of string"false"test_boolean_variables.py)test_ansible_12_boolean_fix.py)Testing
ansible-playbook --syntax-checkpasses for all playbooksImpact
This is a critical fix - all new deployments are currently broken without this change.
Fixes #14833
Test Results
Backwards Compatibility
The fix maintains full backwards compatibility with older Ansible versions while ensuring compatibility with Ansible 12.0.0's strict type checking.