Skip to content

Commit 1cd4203

Browse files
dguidoclaude
andauthored
Fix Ansible 12 compatibility issues (closes #14838) (#14840)
This commit addresses three critical compatibility issues with Ansible 12: 1. **Nested Jinja template deprecation warning** - Fixed: `{{ lookup('file', '{{ SSH_keys.public }}') }}` - Now: `{{ lookup('file', SSH_keys.public) }}` - Location: files/cloud-init/base.sh:20 2. **String to boolean conversion errors in conditionals** - Fixed: `when: item.item` (evaluates strings as truthy) - Now: `when: item.item is defined and item.item != none` - Location: roles/common/tasks/main.yml:20 3. **Sysctl list with None values causing boolean errors** - Restructured list to dynamically exclude None entries - IPv6 forwarding sysctl only added when ipv6_support is true - Location: roles/common/tasks/ubuntu.yml:132 These changes maintain backward compatibility with older Ansible versions while ensuring forward compatibility with Ansible 12's stricter type checking. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude <[email protected]>
1 parent ac9d7b0 commit 1cd4203

File tree

3 files changed

+3
-11
lines changed

3 files changed

+3
-11
lines changed

files/cloud-init/base.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ cat <<EOF >/etc/ssh/sshd_config
1717
EOF
1818

1919
test -d /home/algo/.ssh || sudo -u algo mkdir -m 0700 /home/algo/.ssh
20-
echo "{{ lookup('file', '{{ SSH_keys.public }}') }}" | (sudo -u algo tee /home/algo/.ssh/authorized_keys && chmod 0600 /home/algo/.ssh/authorized_keys)
20+
echo "{{ lookup('file', SSH_keys.public) }}" | (sudo -u algo tee /home/algo/.ssh/authorized_keys && chmod 0600 /home/algo/.ssh/authorized_keys)
2121

2222
ufw --force reset
2323

roles/common/tasks/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
- name: Sysctl tuning
1919
sysctl: name="{{ item.item }}" value="{{ item.value }}"
20-
when: item.item
20+
when: item.item is defined and item.item != none
2121
with_items:
2222
- "{{ sysctl | default([]) }}"
2323
tags:

roles/common/tasks/ubuntu.yml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,7 @@
129129
- openssl
130130
- gnupg2
131131
- cron
132-
sysctl:
133-
- item: net.ipv4.ip_forward
134-
value: 1
135-
- item: net.ipv4.conf.all.forwarding
136-
value: 1
137-
- item: "{{ 'net.ipv6.conf.all.forwarding' if ipv6_support else none }}"
138-
value: 1
139-
- item: net.ipv4.conf.all.route_localnet
140-
value: 1
132+
sysctl: "{{ [{'item': 'net.ipv4.ip_forward', 'value': 1}, {'item': 'net.ipv4.conf.all.forwarding', 'value': 1}, {'item': 'net.ipv4.conf.all.route_localnet', 'value': 1}] + ([{'item': 'net.ipv6.conf.all.forwarding', 'value': 1}] if ipv6_support else []) }}"
141133

142134
- name: Install packages (batch optimization)
143135
include_tasks: packages.yml

0 commit comments

Comments
 (0)