Skip to content

Commit de11b86

Browse files
dguidoclaude
andauthored
fix: detect missing SECP384R1 early and fix community.crypto compatibility (#14970)
Add pre-flight check in main.yml that catches missing cryptography/SECP384R1 before deployment starts, replacing the cryptic error from community.crypto internals with an actionable message pointing users to run ./algo or uv sync. Root cause of the CI ipsec/both test failures: cryptography 46.0.5 wraps the ec module with _ModuleWithDeprecations (for SECT curve deprecation), which breaks community.crypto's ec.__dict__.get("SECP384R1") lookup. The fix in community.crypto 3.1.1 uses getattr() instead. Changes: - Add SECP384R1 pre-flight check to main.yml (conditional on ipsec_enabled) - Add cryptography>=42.0.0 as explicit dependency in pyproject.toml - Upgrade community.crypto to >=3.1.1 (fixes __dict__ vs getattr bug) - Add ansible-galaxy collection install step to CI - Use venv Python interpreter for local deployments in add_host tasks Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent a79d730 commit de11b86

File tree

8 files changed

+28
-4
lines changed

8 files changed

+28
-4
lines changed

.github/workflows/integration-tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ jobs:
5656
- name: Install Python dependencies
5757
run: uv sync
5858

59+
- name: Install Ansible collections
60+
run: uv run ansible-galaxy collection install -r requirements.yml
61+
5962
- name: Create test configuration
6063
run: |
6164
cat > integration-test.cfg << EOF

deploy_client.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
ansible_ssh_user: "{{ 'root' if client_ip == 'localhost' else ssh_user }}"
1414
vpn_user: "{{ vpn_user }}"
1515
IP_subject_alt_name: "{{ server_ip }}"
16-
ansible_python_interpreter: /usr/bin/python3
16+
ansible_python_interpreter: "{% if client_ip == 'localhost' %}{{ ansible_playbook_python }}{% else %}/usr/bin/python3{% endif %}"
1717

1818
- name: Configure the client and install required software
1919
hosts: client-host

main.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,24 @@
6060
You must update the requirements to use this version of Algo.
6161
Try to run: uv sync
6262
63+
- name: Check cryptography library SECP384R1 support
64+
command: >
65+
{{ ansible_playbook_python }} -c
66+
"from cryptography.hazmat.primitives.asymmetric.ec import SECP384R1"
67+
changed_when: false
68+
failed_when: false
69+
register: _crypto_check
70+
when: ipsec_enabled | default(true) | bool
71+
72+
- name: Verify cryptography library supports IPsec requirements
73+
assert:
74+
that: _crypto_check.rc == 0
75+
msg: >
76+
The Python cryptography library is missing or does not support SECP384R1.
77+
IPsec/IKEv2 requires the cryptography package with elliptic curve support.
78+
Fix: Run ./algo (manages dependencies automatically) or: uv sync && uv run ansible-playbook main.yml
79+
when: ipsec_enabled | default(true) | bool
80+
6381
- name: Include prompts playbook
6482
import_playbook: input.yml
6583

playbooks/cloud-post.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
ansible_connection: "{% if cloud_instance_ip == 'localhost' %}local{% else %}ssh{% endif %}"
1111
ansible_ssh_user: "{{ ansible_ssh_user | default('root') }}"
1212
ansible_ssh_port: "{{ ansible_ssh_port | default(22) }}"
13-
ansible_python_interpreter: /usr/bin/python3
13+
ansible_python_interpreter: "{% if cloud_instance_ip == 'localhost' %}{{ ansible_playbook_python }}{% else %}/usr/bin/python3{% endif %}"
1414
algo_provider: "{{ algo_provider }}"
1515
algo_server_name: "{{ algo_server_name }}"
1616
algo_ondemand_cellular: "{{ algo_ondemand_cellular }}"

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ version = "2.0.0-beta"
99
requires-python = ">=3.11"
1010
dependencies = [
1111
"ansible==12.3.0",
12+
"cryptography>=42.0.0",
1213
"jinja2>=3.1.6",
1314
"netaddr==1.3.0",
1415
"pyyaml>=6.0.2",

requirements.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ collections:
77
- name: community.general
88
version: "==11.1.0"
99
- name: community.crypto
10-
version: "==3.0.3"
10+
version: ">=3.1.1"
1111
- name: openstack.cloud
1212
version: "==2.4.1"
1313
- name: linode.cloud

users.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
groups: vpn-host
143143
ansible_ssh_user: "{{ server_user | default('root') }}"
144144
ansible_connection: "{% if algo_server == 'localhost' %}local{% else %}ssh{% endif %}"
145-
ansible_python_interpreter: /usr/bin/python3
145+
ansible_python_interpreter: "{% if algo_server == 'localhost' %}{{ ansible_playbook_python }}{% else %}/usr/bin/python3{% endif %}"
146146
CA_password: "{{ CA_password | default(omit) }}"
147147
rescue:
148148
- include_tasks: playbooks/rescue.yml

uv.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)