mirror of
https://github.com/trailofbits/algo.git
synced 2026-09-22 01:24:58 +02:00
* Simplify codebase: modernize loops, split templates, improve CI This PR consolidates several simplification phases: ## Ansible Modernization - Modernize `with_items` to `loop` across ~50 task files - Add OS detection facts (is_ubuntu, os_family_lowercase) - Condense inline YAML syntax where appropriate ## Template Splitting - Split 568-line dnscrypt-proxy.toml.j2 into focused partials: - global.toml.j2 (core settings) - sources.toml.j2 (resolver sources) - filters.toml.j2 (blocking rules) - cache.toml.j2 (caching config) ## CI Workflow Improvements - Create setup-algo composite action for shared CI setup - Re-enable integration tests with health checks - Fix smart-tests.yml silent lint failures (remove || true) - Use env variables for GitHub SHAs (security) ## server.yml Async Simplification - Reorganize VPN service configuration with clear sections - Add performance_parallel_services toggle - Simplify status display from json_query to inline conditionals - Keep services explicit for readability 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Fix with_items to loop conversion: preserve list flattening with_items automatically flattens nested lists, but loop does NOT. The mechanical conversion broke iteration over list variables. Wrong: loop: - "{{ users }}" # ['alice', 'bob'] treated as ONE item Fixed: loop: "{{ users }}" # Iterates over alice, bob correctly For combined lists (users + server): loop: "{{ users + [IP_subject_alt_name] }}" Fixes IPsec certificate generation creating files named literally '['alice', 'bob'].key' instead of separate alice.key and bob.key. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Fix integration test: use strongswan-starter service name on Ubuntu 20.04+ The StrongSwan service is named 'strongswan-starter' on Ubuntu 20.04+, not 'strongswan'. The test was checking the wrong service name, causing false failures even when StrongSwan was actually running. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Fix IPsec path issues: remove trailing slashes and fix test paths 1. Remove trailing slashes from ipsec_config_path and ipsec_pki_path in roles/strongswan/defaults/main.yml (causes double slashes) 2. Fix integration test to check correct subdirectories: - .p12 files are in ipsec/manual/ - .mobileconfig files are in ipsec/apple/ 3. Fix strongswan service name check (strongswan-starter on Ubuntu 20.04+) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
65 lines
1.8 KiB
YAML
65 lines
1.8 KiB
YAML
---
|
|
# Test the corrected WireGuard async pattern
|
|
- name: Test corrected WireGuard async pattern
|
|
hosts: localhost
|
|
gather_facts: no
|
|
vars:
|
|
test_users: ["testuser1", "testuser2"]
|
|
IP_subject_alt_name: "127.0.0.1"
|
|
wireguard_pki_path: "/tmp/test-fixed-wireguard"
|
|
|
|
tasks:
|
|
- name: Create test directory
|
|
file:
|
|
path: "{{ wireguard_pki_path }}/private"
|
|
state: directory
|
|
mode: '0700'
|
|
|
|
- name: Generate keys (parallel) - simulating wg genkey
|
|
command: echo "mock_private_key_for_{{ item }}"
|
|
register: wg_genkey
|
|
loop: "{{ test_users + [IP_subject_alt_name] }}"
|
|
async: 10
|
|
poll: 0
|
|
|
|
- name: Wait for completion - simulating async_status
|
|
async_status:
|
|
jid: "{{ item.ansible_job_id }}"
|
|
loop: "{{ wg_genkey.results }}"
|
|
register: wg_genkey_results
|
|
until: wg_genkey_results.finished
|
|
retries: 15
|
|
delay: 1
|
|
|
|
- name: Save using CORRECTED pattern - item.item.item
|
|
copy:
|
|
dest: "{{ wireguard_pki_path }}/private/{{ item.item.item }}"
|
|
content: "{{ item.stdout }}"
|
|
mode: "0600"
|
|
when: item.changed
|
|
loop: "{{ wg_genkey_results.results }}"
|
|
|
|
- name: Verify files were created with correct names
|
|
stat:
|
|
path: "{{ wireguard_pki_path }}/private/{{ item }}"
|
|
register: file_check
|
|
loop:
|
|
- "testuser1"
|
|
- "testuser2"
|
|
- "127.0.0.1"
|
|
|
|
- name: Assert all files exist
|
|
assert:
|
|
that:
|
|
- item.stat.exists
|
|
msg: "File should exist: {{ item.stat.path }}"
|
|
loop: "{{ file_check.results }}"
|
|
|
|
- name: Cleanup
|
|
file:
|
|
path: "{{ wireguard_pki_path }}"
|
|
state: absent
|
|
|
|
- debug:
|
|
msg: "✅ WireGuard async fix test PASSED - item.item.item is the correct pattern!"
|