Commit graph

1216 commits

Author SHA1 Message Date
Dan Guido
a87a021d5b Fix Docker build: use --locked without --frozen
The --frozen and --locked flags are mutually exclusive in uv.
Using --locked alone provides the stricter enforcement we want -
it asserts the lockfile won't change and errors if it would.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-06 16:47:38 -07:00
Dan Guido
73d8e99b98 Improve uv installation feedback and Docker dependency locking
- Track and display which installation method succeeded for uv
- Add --locked flag to Docker uv sync for stricter dependency enforcement
- Users now see "uv installed successfully via Homebrew\!" etc.

This addresses code review feedback about installation transparency
and dependency management strictness.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-06 16:44:15 -07:00
Dan Guido
8450e63b56 Remove unused uv installation code from PowerShell script
The PowerShell script is purely a WSL wrapper - it doesn't need to
install uv since it just passes execution to WSL/bash where the Unix
algo script handles dependency management. Removing dead code that
was never called in the execution flow.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-06 16:35:04 -07:00
Dan Guido
9313cc22f2 Address code review feedback
- Add documentation about PATH export scope in algo script
- Optimize Dockerfile layers by combining dependency operations

The PATH export comment clarifies that changes only affect the current
shell session. The Dockerfile change reduces layers by copying and
installing dependencies in a more efficient order.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-06 12:46:18 -07:00
Dan Guido
e7bb35bbff Greatly improve PowerShell script error messages and WSL detection
- Fix WSL detection: only detect when actually running inside WSL
- Add comprehensive error messages with step-by-step WSL installation
- Provide clear troubleshooting guidance for common scenarios
- Add colored output for better visibility (Red/Yellow/Green/Cyan)
- Improve WSL execution with better error handling and path validation
- Clarify Ubuntu 22.04 LTS recommendation for WSL stability
- Add fallback suggestions when things go wrong

Resolves the confusing "bash not recognized" error by properly
detecting Windows vs WSL environments and providing actionable guidance.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-06 12:28:34 -07:00
Dan Guido
7c4a8f2bb5 Fix PowerShell script for Windows Ansible limitations
- Fix syntax issues: remove emoji chars, add winget acceptance flags
- Address core issue: Ansible doesn't run natively on Windows
- Convert PowerShell script to intelligent WSL wrapper
- Auto-detect WSL environment and use appropriate approach
- Provide clear error messages and WSL installation guidance
- Update documentation to reflect WSL requirement
- Maintain backward compatibility for existing WSL users

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-06 11:07:55 -07:00
Dan Guido
51a913c4a5 Add native Windows support with PowerShell script
- Create algo.ps1 for native Windows deployment
- Auto-install uv via winget/scoop with download fallback
- Support update-users command like Unix version
- Add PowerShell linting to CI pipeline with PSScriptAnalyzer
- Update documentation with Windows-specific instructions
- Streamline deploy-from-windows.md with clearer options

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-06 04:50:10 -07:00
Dan Guido
2226e505a6 Clean up test config warnings
- Remove duplicate ipsec_enabled key (was defined twice)
- Remove reserved variable name 'no_log'

This eliminates YAML parsing warnings in the test script while maintaining
the same test functionality.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-06 04:30:59 -07:00
Dan Guido
02bd83e01a Fix CI test failure: use uv-managed ansible in test script
The test script was calling ansible-playbook directly instead of 'uv run ansible-playbook',
which caused it to use the system-installed ansible that doesn't have access to the
netaddr dependency required by the ansible.utils.ipmath filter.

This fixes the CI error: 'Failed to import the required Python library (netaddr)'

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-06 04:30:09 -07:00
Dan Guido
6f3ff69e8f Fix linting and syntax errors caused by FreeBSD removal
- Restore missing newline in roles/dns/handlers/main.yml (broken during FreeBSD cleanup)
- Add FQCN for community.crypto modules in cloud-pre.yml
- Exclude playbooks/ directory from ansible-lint (these are task files, not standalone playbooks)

The FreeBSD removal accidentally removed a trailing newline causing YAML format errors.
The playbook syntax errors were false positives - these files contain tasks for
import_tasks/include_tasks, not standalone plays.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-06 04:25:50 -07:00
Dan Guido
5ca15f24d2 Comprehensive documentation modernization and cleanup
- Remove all FreeBSD support (roles, documentation, references)
- Modernize troubleshooting guide by removing ~200 lines of obsolete content
- Rewrite OpenWrt router documentation with cleaner formatting
- Update Amazon EC2 documentation with current information
- Rewrite unsupported cloud provider documentation
- Remove obsolete linting documentation
- Update all version references to Ubuntu 22.04 LTS and Python 3.11+
- Add documentation style guidelines to CLAUDE.md
- Clean up compilation and legacy Python compatibility issues
- Update client documentation for current requirements

All documentation now reflects the uv-based modernization and current
supported platforms, eliminating references to obsolete tooling and
unsupported operating systems.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-06 04:14:49 -07:00
Dan Guido
4c967c967d Modernize and simplify README installation instructions
- Remove obsolete step 3 (dependency installation) since uv handles this automatically
- Streamline installation from 5 to 4 steps
- Make device section headers consistent (Apple, Android, Windows, Linux)
- Combine Linux WireGuard and IPsec sections for clarity
- Improve "please see this page" links with clear descriptions
- Move PKI preservation note to user management section where it's relevant
- Enhance adding/removing users section with better flow
- Add context to Other Devices section for manual configuration
- Fix grammar inconsistencies (setup → set up, missing commas)
- Update Ubuntu deployment docs to specify 22.04 LTS requirement
- Simplify road warrior setup instructions
- Remove outdated macOS WireGuard complexity notes

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-06 03:39:20 -07:00
Dan Guido
9211d6c299 Update lockfile with cloud provider dependencies and correct version
Regenerates uv.lock to include all optional cloud provider dependencies
and ensures version consistency between pyproject.toml and lockfile.

Added dependencies for all cloud providers:
- AWS: boto3, boto, botocore, s3transfer
- Azure: azure-identity, azure-mgmt-*, msrestazure
- GCP: google-auth, requests
- Hetzner: hcloud
- Linode: linode-api4
- OpenStack: openstacksdk, keystoneauth1
- CloudStack: cs, sshpubkeys

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-06 03:04:41 -07:00
Dan Guido
628728b78a Complete legacy pip module elimination for uv migration
Fixes critical macOS installation failure due to PEP 668 externally-managed-environment restrictions.

Key changes:
- Add missing pyopenssl and segno dependencies to pyproject.toml
- Add optional cloud provider dependencies with exact versions
- Replace all cloud provider pip module tasks with uv-based installation
- Implement dynamic cloud provider dependency installation in cloud-pre.yml
- Modernize OpenStack dependency (openstacksdk replaces deprecated shade)

This completes the migration from legacy pip to modern uv dependency management,
ensuring consistent behavior across all platforms and eliminating the root cause
of macOS installation failures.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-06 03:03:32 -07:00
Dan Guido
6aede4da01 Update community health files for AlgoVPN 2.0
Remove outdated CHANGELOG.md:
- Contained severely outdated information (v1.2, Ubuntu 20.04, Makefile intro)
- Conflicted with current 2.0.0-beta version and recent changes
- 136 lines of misleading content requiring complete rewrite
- GitHub releases provide better, auto-generated changelogs

Modernize CONTRIBUTING.md:
- Update client support: macOS 12+, iOS 15+, Windows 11+, Ubuntu 22.04+
- Expand cloud provider list: Add Vultr, Hetzner, Linode, OpenStack, CloudStack
- Replace manual dependency setup with uv auto-installation
- Add modern development practices: exact dependency pinning, lint.sh usage
- Include development setup section with current workflow

Fix PULL_REQUEST_TEMPLATE.md:
- Fix broken checkboxes: `- []` → `- [ ]` (missing space)
- Add linter compliance requirement: `./scripts/lint.sh`
- Add dependency pinning check for exact versions
- Reorder checklist for logical flow

Community health files now accurately reflect AlgoVPN 2.0 capabilities
and guide contributors toward modern best practices.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-06 02:07:38 -07:00
Dan Guido
dc828c1079 Major packaging improvements for AlgoVPN 2.0 beta
Remove outdated development files and modernize packaging:
- Remove PERFORMANCE.md (optimizations are now defaults)
- Remove Makefile (limited Docker-only utility)
- Remove Vagrantfile (over-engineered for edge case)

Modernize Docker support:
- Fix .dockerignore: 872MB -> 840KB build context (99.9% reduction)
- Update Dockerfile: Python 3.12, uv:latest, better security
- Add multi-arch support and health checks
- Simplified package dependencies

Improve dependency management:
- Pin Ansible collections to exact versions (prevent breakage)
- Update version to 2.0.0-beta for upcoming release
- Align with uv's exact dependency philosophy

This reduces maintenance burden while focusing on Algo's core
cloud deployment use case. Created GitHub issue #14816 for
lazy cloud provider loading in future releases.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-06 02:00:53 -07:00
Dan Guido
40124683d1 Fix shellcheck warning in Ubuntu uv installation menu
Add -r flag to read command to prevent backslash mangling as required
by shellcheck SC2162. This ensures proper handling of user input in
the interactive installation method selection.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-06 01:21:32 -07:00
Dan Guido
2508fbb407 Add Ubuntu-specific uv installation alternatives
Enhance the algo bootstrapping script with Ubuntu-specific trusted
installation methods when system package managers don't provide uv:

- pipx option (official PyPI, ~9 packages vs 58 for python3-pip)
- snap option (community-maintained by Canonical employee)
- Links to source repo for transparency (github.com/lengau/uv-snap)
- Interactive menu with clear explanations
- Robust error handling with fallbacks

Addresses common Ubuntu 24.04+ deployment scenario where uv is not
available via apt, providing secure alternatives to script downloads.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-06 01:17:04 -07:00
Dan Guido
32cc00c9fb Fix ansible version detection for uv-managed environments
Replace pip_package_info lookup with uv pip list command to detect ansible version.
This fixes "'dict object' has no attribute 'ansible'" error on macOS where
ansible is installed via uv instead of system pip.

The fix extracts the ansible package version (e.g. 11.8.0) from uv pip list
output instead of trying to access non-existent pip package registry.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-05 16:06:38 -07:00
Dan Guido
2efaa25c56 Fix pyproject.toml version parsing to not require community.general collection
Replace community.general.toml lookup with regex_search on file lookup.
This fixes "lookup plugin (community.general.toml) not found" error on macOS
where the collection may not be available during early bootstrap.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-05 15:58:11 -07:00
Dan Guido
4b00b8ae5d Fix Python version requirement consistency
Update test to require Python 3.11+ to match pyproject.toml requires-python setting.
Previously test accepted 3.10+ while pyproject.toml required 3.11+.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-05 15:49:52 -07:00
Dan Guido
048a2794ec Complete backward compatibility cleanup and Windows improvements
- Fix main.yml requirements.txt lookup with pyproject.toml parsing
- Update test_docker_localhost_deployment.py to check pyproject.toml
- Fix Vagrantfile pip args with hard-coded dependency versions
- Enhance Windows OS detection for WSL, Git Bash, and MINGW variants
- Implement versioned Windows PowerShell installer (0.8.5)
- Update documentation references in troubleshooting.md and tests/README.md

All linters and tests pass: ruff  yamllint  pytest 48/48  ansible syntax 

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-05 15:44:51 -07:00
Dan Guido
ca97542130 Major improvements: modernize Python tooling, fix CI, enhance security
This commit implements comprehensive improvements across multiple areas:

## 🚀 Python Tooling Modernization
- **Eliminate requirements.txt**: Move to pyproject.toml as single source of truth
- **Add pytest integration**: Replace individual test file execution with pytest discovery
- **Add dev dependencies**: Include pytest and pytest-xdist for parallel testing
- **Update documentation**: Modernize CLAUDE.md with uv-based workflows

## 🔒 Security Enhancements (zizmor fixes)
- **Fix credential persistence**: Add persist-credentials: false to checkout steps
- **Fix template injection**: Move GitHub context variables to environment variables
- **Pin action versions**: Use commit hash for astral-sh/setup-uv@v6 (1ddb97e5078301c0bec13b38151f8664ed04edc8)

##  CI/CD Optimization
- **Create composite action**: Centralize uv setup (.github/actions/setup-uv)
- **Eliminate workflow duplication**: Replace 13 duplicate uv setup blocks with reusable action
- **Fix path filters**: Update smart-tests.yml to watch pyproject.toml instead of requirements.txt
- **Remove pip caching**: Clean up obsolete cache: 'pip' configurations
- **Standardize test execution**: Use pytest across all workflows

## 🐳 Docker Improvements
- **Secure uv installation**: Use official distroless image instead of curl
- **Remove requirements.txt**: Update COPY directive for new dependency structure

## 📈 Impact Summary
- **Security**: Resolved 12/14 zizmor issues (86% improvement)
- **Maintainability**: 92% reduction in workflow duplication
- **Performance**: Better caching and parallel test execution
- **Standards**: Aligned with 2025 Python packaging best practices

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-05 15:31:23 -07:00
Dan Guido
cb0a492307 Implement secure uv installation addressing Claude's security concerns
Security improvements:
- **Package managers first**: Try brew, apt, dnf, pacman, zypper, winget, scoop
- **User consent required**: Clear security warning before script download
- **Manual installation guidance**: Provide fallback instructions with checksums
- **Versioned installers**: Use uv 0.8.5 specific URLs for consistency across CI/local

Benefits:
-  Most users get uv via secure package managers (no download needed)
-  Clear security disclosure for script downloads with opt-out
-  Transparent about security tradeoffs vs usability
-  Maintains "just works" experience while respecting security concerns
-  CI and local installations now use identical versioned scripts

This addresses the unverified download security vulnerability while preserving
the user experience improvements from the self-bootstrapping approach.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-05 14:56:00 -07:00
Dan Guido
9e0a1770d8 Remove obsolete venvs directory and update .gitignore for uv
- Remove venvs/ directory which was only used as a placeholder for virtualenv
- Update .gitignore to use explicit .env/ and .venv/ patterns instead of *env
- Modernize ignore patterns for uv-based dependency management

🤖 Generated with [Claude Code](https://claude.ai/code)
2025-08-05 14:48:08 -07:00
Dan Guido
97e4d89a20 Remove test configuration file 2025-08-05 14:44:43 -07:00
Dan Guido
ce49f27250 Fix CI/CD workflow inconsistencies and resolve Claude's code review issues
- Fix inconsistent dependency management across all CI workflows
  - Replace 'uv add' with 'uv sync' for reproducible builds
  - Use 'uv run --with' for temporary tool installations
  - Standardize on locked dependencies from pyproject.toml

- Fix ineffective linting by removing '|| true' from ruff check in lint.yml
  - Ensures linting errors actually fail the build
  - Maintains consistency with other linter configurations

- Update yamllint configuration to exclude .venv/ directory
  - Prevents scanning Python package templates with Ansible-specific filters
  - Fixes trailing spaces in workflow files

- Improve shell script quality by fixing shellcheck warnings
  - Quote $(pwd) expansions in Docker test scripts
  - Address critical word-splitting vulnerabilities

- Update test infrastructure for uv compatibility
  - Exclude .env/.venv directories from template scanning
  - Ensure local tests exactly match CI workflow commands

All linters and tests now pass locally and match CI requirements exactly.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-05 14:44:27 -07:00
Dan Guido
5c498b9de7 Implement self-bootstrapping uv setup to resolve issue #14776
This major simplification addresses the Python setup complexity that
has been a barrier for non-developer users deploying Algo VPN.

## Revolutionary User Experience Change

**Before (complex):**
```bash
python3 -m virtualenv --python="$(command -v python3)" .env &&
  source .env/bin/activate &&
  python3 -m pip install -U pip virtualenv &&
  python3 -m pip install -r requirements.txt
./algo
```

**After (simple):**
```bash
./algo
```

## Key Technical Changes

### Core Implementation
- **algo script**: Complete rewrite with automatic uv installation
  - Detects missing uv and installs automatically via curl
  - Cross-platform support (macOS, Linux, Windows)
  - Preserves exact same command interface
  - Uses `uv run ansible-playbook` instead of virtualenv activation

### Documentation Overhaul
- **README.md**: Reduced installation from 4 complex steps to 1 command
- **Platform docs**: Simplified macOS, Windows, Linux, Cloud Shell guides
- **Removed Python installation complexity** from all user-facing docs

### CI/CD Infrastructure Updates
- **5 GitHub Actions workflows** converted from pip to uv
- **Docker builds** updated to use uv instead of virtualenv
- **Legacy test scripts** (3 files) updated for uv compatibility

### Repository Cleanup
- **install.sh**: Updated for cloud-init/bootstrap scenarios
- **algo-showenv.sh**: Updated environment detection for uv
- **pyproject.toml**: Added all dependencies with proper versioning
- **test scripts**: Removed .env references, updated paths

## Benefits Achieved

 **Zero-step dependency installation** - uv installs automatically on first run
 **Cross-platform consistency** - identical experience on all operating systems
 **Automatic Python version management** - uv handles Python 3.11+ requirement
 **Familiar interface preserved** - existing `./algo` and `./algo update-users` unchanged
 **No breaking changes** - existing users see same commands, same functionality
 **Resolves macOS Python compatibility** - works with system Python 3.9 via uv's Python management

## Files Changed (18 total)

**Core Scripts (3)**:
- algo (complete rewrite with self-bootstrapping)
- algo-showenv.sh (uv environment detection)
- install.sh (cloud-init script updated)

**Documentation (4)**:
- README.md (revolutionary simplification)
- docs/deploy-from-macos.md (removed Python complexity)
- docs/deploy-from-windows.md (simplified WSL setup)
- docs/deploy-from-cloudshell.md (updated for uv)

**CI/CD (5)**:
- .github/workflows/main.yml (pip → uv conversion)
- .github/workflows/smart-tests.yml (pip → uv conversion)
- .github/workflows/lint.yml (pip → uv conversion)
- .github/workflows/integration-tests.yml (pip → uv + Docker fix)
- Dockerfile (virtualenv → uv conversion)

**Tests (4)**:
- tests/legacy-lxd/local-deploy.sh (virtualenv → uv in Docker)
- tests/legacy-lxd/update-users.sh (virtualenv → uv in Docker)
- tests/legacy-lxd/ca-password-fix.sh (virtualenv → uv in Docker)
- tests/unit/test_template_rendering.py (removed .env path reference)

**Dependencies (2)**:
- pyproject.toml (added full dependency specification)
- uv.lock (new uv lockfile for reproducible builds)

This implementation makes Algo VPN accessible to non-technical users while
maintaining all power and flexibility for advanced users.

Closes #14776

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-05 14:33:18 -07:00
dependabot[bot]
b980586bc0
Bump docker/login-action from 3.4.0 to 3.5.0 (#14813) 2025-08-05 11:03:45 -07:00
Jack Ivanov
4289db043a
Refactor StrongSwan PKI tasks to use Ansible crypto modules and remove legacy OpenSSL scripts (#14809)
* Refactor StrongSwan PKI automation with Ansible crypto modules

- Replace shell-based OpenSSL commands with community.crypto modules
- Remove custom OpenSSL config template and manual file management
- Upgrade Ansible to 11.8.0 in requirements.txt
- Improve idempotency, maintainability, and security of certificate and CRL handling

* Enhance nameConstraints with comprehensive exclusions

- Add email domain exclusions (.com, .org, .net, .gov, .edu, .mil, .int)
- Include private IPv4 network exclusions
- Add IPv6 null route exclusion
- Preserve all security constraints from original openssl.cnf.j2
- Note: Complex IPv6 conditional logic simplified for Ansible compatibility

Security: Maintains defense-in-depth certificate scope restrictions

* Refactor StrongSwan PKI with comprehensive security enhancements and hybrid testing

## StrongSwan PKI Modernization
- Migrated from shell-based OpenSSL commands to Ansible community.crypto modules
- Simplified complex Jinja2 templates while preserving all security properties
- Added clear, concise comments explaining security rationale and Apple compatibility

## Enhanced Security Implementation (Issues #75, #153)
- **Name constraints**: CA certificates restricted to specific IP/email domains
- **EKU role separation**: Server certs (serverAuth only) vs client certs (clientAuth only)
- **Domain exclusions**: Blocks public domains (.com, .org, etc.) and private IP ranges
- **Apple compatibility**: SAN extensions and PKCS#12 compatibility2022 encryption
- **Certificate revocation**: Automated CRL generation for removed users

## Comprehensive Test Suite
- **Hybrid testing**: Validates real certificates when available, config validation for CI
- **Security validation**: Verifies name constraints, EKU restrictions, role separation
- **Apple compatibility**: Tests SAN extensions and PKCS#12 format compliance
- **Certificate chain**: Validates CA signing and certificate validity periods
- **CI-compatible**: No deployment required, tests Ansible configuration directly

## Configuration Updates
- Updated CLAUDE.md: Ansible version rationale (stay current for security/performance)
- Streamlined comments: Removed duplicative explanations while preserving technical context
- Maintained all Issue #75/#153 security enhancements with modern Ansible approach

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix linting issues across the codebase

## Python Code Quality (ruff)
- Fixed import organization and removed unused imports in test files
- Replaced `== True` comparisons with direct boolean checks
- Added noqa comments for intentional imports in test modules

## YAML Formatting (yamllint)
- Removed trailing spaces in openssl.yml comments
- All YAML files now pass yamllint validation (except one pre-existing long regex line)

## Code Consistency
- Maintained proper import ordering in test files
- Ensured all code follows project linting standards
- Ready for CI pipeline validation

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Replace magic number with configurable certificate validity period

## Maintainability Improvement
- Replaced hardcoded `+3650d` (10 years) with configurable variable
- Added `certificate_validity_days: 3650` in vars section with clear documentation
- Applied consistently to both server and client certificate signing

## Benefits
- Single location to modify certificate validity period
- Supports compliance requirements for shorter certificate lifespans
- Improves code readability and maintainability
- Eliminates magic number duplication

## Backwards Compatibility
- Default remains 10 years (3650 days) - no behavior change
- Organizations can now easily customize certificate validity as needed

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Update test to validate configurable certificate validity period

## Test Update
- Fixed test failure after replacing magic number with configurable variable
- Now validates both variable definition and usage patterns:
  - `certificate_validity_days: 3650` (configurable parameter)
  - `ownca_not_after: "+{{ certificate_validity_days }}d"` (variable usage)

## Improved Test Coverage
- Better validation: checks that validity is configurable, not hardcoded
- Maintains backwards compatibility verification (10-year default)
- Ensures proper Ansible variable templating is used

## Verified
- Config validation mode: All 6 tests pass ✓
- Validates the maintainability improvement from previous commit

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Update to Python 3.11 minimum and fix IPv6 constraint format

- Update Python requirement from 3.10 to 3.11 to align with Ansible 11
- Pin Ansible collections in requirements.yml for stability
- Fix invalid IPv6 constraint format causing deployment failure
- Update ruff target-version to py311 for consistency

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix x509_crl mode parameter and auto-fix Python linting

- Remove deprecated 'mode' parameter from x509_crl task
- Add separate file task to set CRL permissions (0644)
- Auto-fix Python datetime import (use datetime.UTC alias)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix final IPv6 constraint format in defaults template

- Update nameConstraints template in defaults/main.yml
- Change malformed IP:0:0:0:0:0:0:0:0/0:0:0:0:0:0:0:0 to correct IP:::/0
- This ensures both Ansible crypto modules and OpenSSL template use consistent IPv6 format

* Fix critical certificate generation issues for macOS/iOS VPN compatibility

This commit addresses multiple certificate generation bugs in the Ansible crypto
module implementation that were causing VPN authentication failures on Apple devices.

Fixes implemented:

1. **Basic Constraints Extension**: Added missing `CA:FALSE` constraints to both
   server and client certificate CSRs. This was causing certificate chain validation
   errors on macOS/iOS devices.

2. **Subject Key Identifier**: Added `create_subject_key_identifier: true` to CA
   certificate generation to enable proper Authority Key Identifier creation in
   signed certificates.

3. **Complete Name Constraints**: Fixed missing DNS and IPv6 constraints in CA
   certificate that were causing size differences compared to legacy shell-based
   generation. Now includes:
   - DNS constraints for the deployment-specific domain
   - IPv6 permitted addresses when IPv6 support is enabled
   - Complete IPv6 exclusion ranges (fc00::/7, fe80::/10, 2001:db8::/32)

These changes bring the certificate format much closer to the working shell-based
implementation and should resolve most macOS/iOS VPN connectivity issues.

**Outstanding Issue**: Authority Key Identifier still incomplete - missing DirName
and serial components. The community.crypto module limitation may require
additional investigation or alternative approaches.

Certificate size improvements: Server certificates increased from ~750 to ~775 bytes,
CA certificates from ~1070 to ~1250 bytes, bringing them closer to the expected
~3000 byte target size.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix certificate generation and improve version parsing

This commit addresses multiple issues found during macOS certificate validation:

Certificate Generation Fixes:
- Add Basic Constraints (CA:FALSE) to server and client certificates
- Generate Subject Key Identifier for proper AKI creation
- Improve Name Constraints implementation for security
- Update community.crypto to version 3.0.3 for latest fixes

Code Quality Improvements:
- Clean up certificate comments and remove obsolete references
- Fix server certificate identification in tests
- Update datetime comparisons for cryptography library compatibility
- Fix Ansible version parsing in main.yml with proper regex handling

Testing:
- All certificate validation tests pass
- Ansible syntax checks pass
- Python linting (ruff) clean
- YAML linting (yamllint) clean

These changes restore macOS/iOS certificate compatibility while maintaining
security best practices and improving code maintainability.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Enhance security documentation with comprehensive inline comments

Add detailed technical explanations for critical PKI security features:

- Name Constraints: Defense-in-depth rationale and attack prevention
- Public domain/network exclusions: Impersonation attack prevention
- RFC 1918 private IP blocking: Lateral movement prevention
- IPv6 constraint strategy: ULA/link-local/documentation range handling
- Role separation enforcement: Server vs client EKU restrictions
- CA delegation prevention: pathlen:0 security implications
- Cross-deployment isolation: UUID-based certificate scope limiting

These comments provide essential context for maintainers to understand
the security importance of each configuration without referencing
external issue numbers, ensuring long-term maintainability.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix CI test failures in PKI certificate validation

Resolve Smart Test Selection workflow failures by fixing test validation logic:

**Certificate Configuration Fixes:**
- Remove unnecessary serverAuth/clientAuth EKUs from CA certificate
- CA now only has IPsec End Entity EKU for VPN-specific certificate issuance
- Maintains proper role separation between server and client certificates

**Test Validation Improvements:**
- Fix domain exclusion detection to handle both single and double quotes in YAML
- Improve EKU validation to check actual configuration lines, not comments
- Server/client certificate tests now correctly parse YAML structure
- Tests pass in both CI mode (config validation) and local mode (real certificates)

**Root Cause:**
The CI failures were caused by overly broad test assertions that:
1. Expected double-quoted strings but found single-quoted YAML
2. Detected EKU keywords in comments rather than actual configuration
3. Failed to properly parse YAML list structures

All security constraints remain intact - no actual security issues were present.
The certificate generation produces properly constrained certificates for VPN use.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix trailing space in openssl.yml for yamllint compliance

---------

Co-authored-by: Dan Guido <dan@trailofbits.com>
Co-authored-by: Claude <noreply@anthropic.com>
2025-08-05 05:40:28 -07:00
Dan Guido
0aaca43019
Security Hardening and Certificate Authority Constraints (#14811)
* Security hardening and certificate authority constraints

This commit addresses Issues #75 and #14804 with defensive security
enhancements that provide additional protection layers for edge case
scenarios.

## Issue #75: Technically Constrain Root CA
- Add pathlen:0 basic constraints preventing subordinate CA creation
- Implement name constraints restricting certificate issuance to specific IPs
- Add extended key usage restrictions limiting CA scope to VPN certificates
- Separate client/server certificate extensions (serverAuth vs clientAuth)
- Enhanced CA with critical constraints for defense-in-depth when CA keys saved

## Issue #14804: Comprehensive SystemD Security Hardening
- WireGuard: Added systemd hardening as additional defense-in-depth
- StrongSwan: Enhanced systemd configuration complementing AppArmor profiles
- dnscrypt-proxy: Additional systemd security alongside AppArmor protection
- Applied privilege restrictions, filesystem isolation, and system call filtering

## Technical Changes
- CA certificate constraints only relevant when users opt to save CA keys
- SystemD hardening provides additional isolation layers beyond existing AppArmor
- Enhanced client certificate validation for iOS/macOS profiles
- Reliable AppArmor profile enforcement for Ubuntu 22.04

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Address PR review feedback and improve code quality

## Fixes Based on Review Feedback:

### Handler Consistency Issues
- Fix notification naming: "daemon reload" → "daemon-reload" for consistency
- Update deprecated syntax: `daemon_reload: yes` → `daemon_reload: true`

### Enhanced CA Certificate Constraints
- Add .mil and .int to excluded DNS domains for completeness
- Add .mil and .int to excluded email domains for consistency
- Add explanatory comment for openssl_constraint_random_id security purpose

## Technical Improvements:
- Ensures proper handler invocation across DNS and WireGuard services
- Provides more comprehensive CA name constraints protection
- Documents the security rationale for UUID-based CA constraints

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Address PR review feedback - improve documentation and fix duplicate key

- Add IPv6 documentation range (2001:db8::/32) to excluded ranges
- Add explanatory comment for CA name constraints defense-in-depth purpose
- Remove duplicate DisableMOBIKE key from iOS configuration
- Add comprehensive comments to iOS/macOS mobileconfig parameters
- Explain MOBIKE, redirect disabling, certificate type, and routing settings

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-08-04 20:22:41 -07:00
dependabot[bot]
9e0de205fb
Bump actions/setup-python from 5.2.0 to 5.6.0 (#14806)
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 5.2.0 to 5.6.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](f677139bbe...a26af69be9)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-version: 5.6.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-08-04 10:24:59 -07:00
dependabot[bot]
5e7fdee7b7
Bump docker/build-push-action from 6.9.0 to 6.18.0 (#14808)
Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 6.9.0 to 6.18.0.
- [Release notes](https://github.com/docker/build-push-action/releases)
- [Commits](4f58ea7922...263435318d)

---
updated-dependencies:
- dependency-name: docker/build-push-action
  dependency-version: 6.18.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-08-04 10:24:41 -07:00
Jack Ivanov
5214c5f819
Refactor WireGuard key management (#14803)
* Refactor WireGuard key management: generate all keys locally with Ansible modules

- Move all WireGuard key generation from remote hosts to local execution via Ansible modules
- Enhance x25519_pubkey module for robust, idempotent, and secure key handling
- Update WireGuard role tasks to use local key generation and management
- Improve error handling and support for check mode

* Improve x25519_pubkey module code quality and add integration tests

Code Quality Improvements:
- Fix import organization and Ruff linting errors
- Replace bare except clauses with practical error handling
- Simplify documentation while maintaining useful debugging info
- Use dictionary literals instead of dict() calls for better performance

New Integration Test:
- Add comprehensive WireGuard key generation test (test_wireguard_key_generation.py)
- Tests actual deployment scenarios matching roles/wireguard/tasks/keys.yml
- Validates mathematical correctness of X25519 key derivation
- Tests both file and string input methods used by Algo
- Includes consistency validation and WireGuard tool integration
- Addresses documented test gap in tests/README.md line 63-67

Test Coverage:
- Module import validation
- Raw private key file processing
- Base64 private key string processing
- Key derivation consistency checks
- Optional WireGuard tool validation (when available)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Trigger CI build for PR #14803

Testing x25519_pubkey module improvements and WireGuard key generation changes.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix yamllint error: add missing newline at end of keys.yml

Resolves: no new line character at the end of file (new-line-at-end-of-file)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix critical binary data corruption bug in x25519_pubkey module

Issue: Private keys with whitespace-like bytes (0x09, 0x0A, etc.) at edges
were corrupted by .strip() call on binary data, causing 32-byte keys to
become 31 bytes and deployment failures.

Root Cause:
- Called .strip() on raw binary data unconditionally
- X25519 keys containing whitespace bytes were truncated
- Error: "got 31 bytes" instead of expected 32 bytes

Fix:
- Only strip whitespace when processing base64 text data
- Preserve raw binary data integrity for 32-byte keys
- Maintain backward compatibility with both formats

Addresses deployment failure: "Private key file must be either base64
or exactly 32 raw bytes, got 31 bytes"

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Add inline comments to prevent binary data corruption bug

Explain the base64/raw file detection logic with clear warnings about
the critical issue where .strip() on raw binary data corrupts X25519
keys containing whitespace-like bytes (0x09, 0x0A, etc.).

This prevents future developers from accidentally reintroducing the
'got 31 bytes' deployment error by misunderstanding the dual-format
key handling logic.

---------

Co-authored-by: Dan Guido <dan@trailofbits.com>
Co-authored-by: Claude <noreply@anthropic.com>
2025-08-03 18:24:12 -07:00
Dan Guido
146e2dcf24
Fix IPv6 address selection on BSD systems (#14786)
* fix: Fix IPv6 address selection on BSD systems (#1843)

BSD systems return IPv6 addresses in the order they were added to the interface,
not sorted by scope like Linux. This causes ansible_default_ipv6 to contain
link-local addresses (fe80::) with interface suffixes (%em0) instead of global
addresses, breaking certificate generation.

This fix:
- Adds a new task file to properly select global IPv6 addresses on BSD
- Filters out link-local addresses and interface suffixes
- Falls back to ansible_all_ipv6_addresses when needed
- Ensures certificates are generated with valid global IPv6 addresses

The workaround is implemented in Algo rather than waiting for the upstream
Ansible issue (#16977) to be fixed, which has been open since 2016.

Fixes #1843

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* chore: Remove duplicate condition in BSD IPv6 facts

Removed redundant 'global_ipv6_address is not defined' condition
that was checked twice in the same when clause.

* improve: simplify regex for IPv6 interface suffix removal

Change regex from '(.*)%.*' to '%.*' for better readability
and performance when stripping interface suffixes from IPv6 addresses.

The simplified regex is equivalent but more concise and easier to understand.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: resolve yamllint trailing spaces in BSD IPv6 test

Remove trailing spaces from test_bsd_ipv6.yml to ensure CI passes

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: resolve yamllint issues across repository

- Remove trailing spaces from server.yml, WireGuard test files, and keys.yml
- Add missing newlines at end of test files
- Ensure all YAML files pass yamllint validation for CI

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-08-03 17:15:27 -07:00
Dan Guido
358d50314e
feat: Add comprehensive performance optimizations to reduce deployment time by 30-60%
This PR introduces comprehensive performance optimizations that reduce Algo VPN deployment time by 30-60% while maintaining security and reliability.

Key improvements:
- Fixed critical WireGuard async structure bug (item.item.item pattern)
- Resolved merge conflicts in test-aws-credentials.yml 
- Fixed path concatenation issues and aesthetic double slash problems
- Added comprehensive performance optimizations with configurable flags
- Extensive testing and quality improvements with yamllint/ruff compliance

Successfully deployed and tested on DigitalOcean with all optimizations disabled.
All critical bugs resolved and PR is production-ready.
2025-08-03 16:42:17 -07:00
Dan Guido
a4e647ce71
docs: Add Windows client documentation and common error fix (#14787)
- Added comprehensive Windows client setup guide (docs/client-windows.md)
- Documented the common "parameter is incorrect" error in troubleshooting.md
- Added step-by-step solution for Windows networking stack reset
- Included WireGuard setup instructions and common issues
- Added Windows documentation links to README.md

This addresses the frequently reported issue #1051 where Windows users
encounter "parameter is incorrect" errors when connecting to Algo VPN.
The fix involves resetting Windows networking components and has helped
many users resolve their connection issues.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Claude <noreply@anthropic.com>
2025-08-03 15:20:58 -06:00
Dan Guido
8ee15e6966
feat: Add AWS credentials file support (#14778)
* feat: Add AWS credentials file support

- Automatically reads AWS credentials from ~/.aws/credentials
- Supports AWS_PROFILE and AWS_SHARED_CREDENTIALS_FILE environment variables
- Adds support for temporary credentials with session tokens
- Maintains backward compatibility with existing credential methods
- Follows standard AWS credential precedence order

Based on PR #14460 by @lefth with the following improvements:
- Fixed variable naming to match existing code (access_key vs aws_access_key)
- Added session token support for temporary credentials
- Integrated credential discovery directly into prompts.yml
- Added comprehensive tests
- Added documentation

Closes #14382

* fix ansible lint

---------

Co-authored-by: Jack Ivanov <17044561+jackivanov@users.noreply.github.com>
2025-08-03 15:07:57 -06:00
Dan Guido
bb8db7d877
feat: add support for vultr api v2 (#14773)
Co-authored-by: Dhruv Kelawala <dhruvrk2000@gmail.com>
2025-08-03 14:56:40 -06:00
Dan Guido
c495307027
Fix DigitalOcean cloud-init compatibility and deprecation warnings (#14801)
* Fix DigitalOcean cloud-init compatibility issue causing SSH timeout on port 4160

This commit addresses the issue described in GitHub issue #14800 where DigitalOcean
deployments fail during the "Wait until SSH becomes ready..." step due to cloud-init
not processing the write_files directive correctly.

## Problem
- DigitalOcean's cloud-init shows "Unhandled non-multipart (text/x-not-multipart) userdata" warning
- write_files module gets skipped, leaving SSH on default port 22 instead of port 4160
- Algo deployment times out when trying to connect to port 4160

## Solution
Added proactive detection and remediation to the DigitalOcean role:
1. Check if SSH is listening on the expected port (4160) after droplet creation
2. If not, automatically apply the SSH configuration manually via SSH on port 22
3. Verify SSH is now listening on the correct port before proceeding

## Changes
- Added SSH port check with 30-second timeout
- Added fallback remediation block that:
  - Connects via SSH on port 22 to apply Algo's SSH configuration
  - Backs up the original sshd_config
  - Applies the correct SSH settings (port 4160, security hardening)
  - Restarts the SSH service
  - Verifies the fix worked

This ensures DigitalOcean deployments succeed even when cloud-init fails to process
the user_data correctly, maintaining backward compatibility and reliability.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Implement cleaner fix for DigitalOcean cloud-init encoding issue

This replaces the previous workaround with two targeted fixes that address
the root cause of the "Unhandled non-multipart (text/x-not-multipart) userdata"
issue that prevents write_files from being processed.

## Root Cause
Cloud-init receives user_data as binary/bytes instead of UTF-8 string,
causing it to fail parsing and skip the write_files directive that
configures SSH on port 4160.

## Cleaner Solutions Implemented

### Fix 1: String Encoding (user_data | string)
- Added explicit string conversion to user_data template lookup
- Ensures DigitalOcean API receives proper UTF-8 string, not bytes
- Minimal change with maximum compatibility

### Fix 2: Use runcmd Instead of write_files
- Replaced write_files approach with runcmd shell commands
- Bypasses the cloud-init parsing issue entirely
- More reliable as it executes direct shell commands
- Includes automatic SSH config backup for safety

## Changes Made
- `roles/cloud-digitalocean/tasks/main.yml`: Added | string filter to user_data
- `files/cloud-init/base.yml`: Replaced write_files with runcmd approach
- Removed complex SSH detection/remediation workaround (no longer needed)

## Benefits
-  Fixes root cause instead of working around symptoms
-  Much simpler and more maintainable code
-  Backward compatible - no API changes required
-  Handles both potential failure modes (encoding + parsing)
-  All tests pass, linters clean

This should resolve DigitalOcean SSH timeout issues while being much
cleaner than the previous workaround approach.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix cloud-init header format for DigitalOcean compatibility

The space in '# cloud-config' (introduced in PR #14775) breaks cloud-init
YAML parsing on DigitalOcean, causing SSH configuration to be skipped.

Cloud-init documentation requires '#cloud-config' without a space.

Fixes #14800

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Revert to write_files approach for SSH configuration

Using write_files is more maintainable and Ansible-native than runcmd.
The root cause was the cloud-config header format, not write_files itself.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix Ansible deprecation and variable warnings

- Replace deprecated network filters with ansible.utils equivalents:
  - ipaddr → ansible.utils.ipaddr
  - ipmath → ansible.utils.ipmath
  - ipv4 → ansible.utils.ipv4
  - ipv6 → ansible.utils.ipv6
  - next_nth_usable → ansible.utils.next_nth_usable

- Fix reserved variable name: no_log → algo_no_log

- Fix SSH user groups warning by explicitly specifying groups parameter

Addresses deprecation warnings that would become errors after 2024-01-01.
All linter checks pass with only cosmetic warnings remaining.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Add comprehensive protection for cloud-config header format

- Add inline documentation explaining critical #cloud-config format requirement
- Exclude files/cloud-init/ from yamllint and ansible-lint to prevent automatic 'fixes'
- Create detailed README.md documenting the issue and protection measures
- Reference GitHub issue #14800 for future maintainers

This prevents regression of the critical cloud-init header format that
causes deployment failures when changed from '#cloud-config' to '# cloud-config'.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Add test for cloud-init header format to prevent regression

This test ensures the cloud-init header remains exactly ''#cloud-config''
without a space. The regression in PR #14775 that added a space broke
DigitalOcean deployments by causing cloud-init YAML parsing to fail,
resulting in SSH timeouts on port 4160.

Co-authored-by: Dan Guido <dguido@users.noreply.github.com>

* Refactor SSH config template and fix MOTD task permissions

- Use dedicated sshd_config template instead of inline content
- Add explicit become: true to MOTD task to fix permissions warning

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix no_log variable references after renaming to algo_no_log

Update all remaining references from old 'no_log' variable to 'algo_no_log'
in WireGuard, SSH tunneling, and StrongSwan roles. This fixes deployment
failures caused by undefined variable references.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: Correct YAML indentation in cloud-init template for DigitalOcean

The indent filter was not indenting the first line of the sshd_config content,
causing invalid YAML structure that cloud-init couldn't parse. This resulted
in SSH timeouts during deployment as the port was never changed from 22 to 4160.

- Add first=True parameter to indent filter to ensure all lines are indented
- Remove extra indentation in base template to prevent double-indentation
- Add comprehensive test suite to validate template rendering and prevent regressions

Fixes deployment failures where cloud-init would show:
"Invalid format at line X: expected <block end>, but found '<scalar>'"

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Co-authored-by: Dan Guido <dguido@users.noreply.github.com>
2025-08-03 14:25:47 -04:00
dependabot[bot]
0ddd994ff4
Bump docker/metadata-action from 5.5.1 to 5.8.0 (#14797)
Bumps [docker/metadata-action](https://github.com/docker/metadata-action) from 5.5.1 to 5.8.0.
- [Release notes](https://github.com/docker/metadata-action/releases)
- [Commits](8e5442c4ef...c1e51972af)

---
updated-dependencies:
- dependency-name: docker/metadata-action
  dependency-version: 5.8.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-08-03 08:02:22 -04:00
dependabot[bot]
67051d8d35
Bump actions/checkout from 4.1.7 to 4.2.2 (#14796)
Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.7 to 4.2.2.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](692973e3d9...11bd71901b)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: 4.2.2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-08-03 08:02:16 -04:00
dependabot[bot]
be77fe25d0
Bump docker/login-action from 3.3.0 to 3.4.0 (#14795)
Bumps [docker/login-action](https://github.com/docker/login-action) from 3.3.0 to 3.4.0.
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](9780b0c442...74a5d14239)

---
updated-dependencies:
- dependency-name: docker/login-action
  dependency-version: 3.4.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-08-03 08:02:06 -04:00
dependabot[bot]
5db7b17f4e
Bump dorny/paths-filter from 2.11.1 to 3.0.2 (#14794)
Bumps [dorny/paths-filter](https://github.com/dorny/paths-filter) from 2.11.1 to 3.0.2.
- [Release notes](https://github.com/dorny/paths-filter/releases)
- [Changelog](https://github.com/dorny/paths-filter/blob/master/CHANGELOG.md)
- [Commits](4512585405...de90cc6fb3)

---
updated-dependencies:
- dependency-name: dorny/paths-filter
  dependency-version: 3.0.2
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-08-03 08:01:58 -04:00
dependabot[bot]
0d49dd3e33
Bump actions/upload-artifact from 4.3.1 to 4.6.2 (#14793)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.3.1 to 4.6.2.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](5d5d22a312...ea165f8d65)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: 4.6.2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-08-03 08:01:50 -04:00
Dan Guido
d961f1d7e0
Add Claude Code GitHub Workflow (#14798)
* "Claude PR Assistant workflow"

* "Claude Code Review workflow"

* docs: Add CLAUDE.md for LLM guidance

This comprehensive guide captures important context and learnings for LLMs
working on the Algo VPN codebase, including:

- Project architecture and structure
- Critical dependencies and version management
- Development practices and code style
- Testing requirements and CI/CD pipeline
- Common issues and solutions
- Security considerations
- Platform support details
- Maintenance guidelines

The guide emphasizes Algo's core values: security, simplicity, and privacy.
It provides practical guidance based on extensive experience working with
the codebase, helping future contributors maintain high standards while
avoiding common pitfalls.

* feat: Configure Claude GitHub Actions with Algo-specific settings

- Add allowed_tools for running Ansible, Python, and shell linters
- Enable use_sticky_comment for cleaner PR discussions
- Add custom_instructions to follow Algo's security-first principles
- Reference CLAUDE.md for project-specific guidance
2025-08-03 08:01:41 -04:00
Dan Guido
be744b16a2
chore: Conservative dependency updates for Jinja2 security fix (#14792)
* chore: Conservative dependency updates for security

- Update Ansible from 9.1.0 to 9.2.0 (one minor version bump only)
- Update Jinja2 to ~3.1.6 to fix CVE-2025-27516 (critical security fix)
- Pin netaddr to 1.3.0 (current stable version)

This is a minimal, conservative update focused on:
1. Critical security fix for Jinja2
2. Minor ansible update for bug fixes
3. Pinning netaddr to prevent surprises

No changes to Ansible collections - keeping them unpinned for now.

* fix: Address linter issues (ruff, yamllint, shellcheck)

- Fixed ruff configuration by moving linter settings to [tool.ruff.lint] section
- Fixed ruff code issues:
  - Moved imports to top of files (E402)
  - Removed unused variables or commented them out
  - Updated string formatting from % to .format()
  - Replaced dict() calls with literals
  - Fixed assert False usage in tests
- Fixed yamllint issues:
  - Added missing newlines at end of files
  - Removed trailing spaces
  - Added document start markers (---) to YAML files
  - Fixed 'on:' truthy warnings in GitHub workflows
- Fixed shellcheck issues:
  - Properly quoted variables in shell scripts
  - Fixed A && B || C pattern with proper if/then/else
  - Improved FreeBSD rc script quoting

All linters now pass without errors related to our code changes.

* fix: Additional yamllint fixes for GitHub workflows

- Added document start markers (---) to test-effectiveness.yml
- Fixed 'on:' truthy warning by quoting as 'on:'
- Removed trailing spaces from main.yml
- Added missing newline at end of test-effectiveness.yml
2025-08-03 07:45:26 -04:00
Dan Guido
49aa9c49a4
docs: Add sudo requirement for local installations (#14790)
This addresses the issue reported in PR #14173 where local installations
fail with 'sudo: a password is required' error. The sudo requirement is
now properly documented in the local installation guide rather than the
main README.

When installing Algo locally (on the same system where the scripts are
installed), administrative privileges are required to configure system
services and network settings.
2025-08-03 07:04:17 -04:00
Dan Guido
640249ae59
fix: Fix shellcheck POSIX sh issue and make ansible-lint stricter (#14789)
* fix: Remove POSIX-incompatible 'local' keyword from install.sh

The install.sh script uses #\!/usr/bin/env sh (POSIX shell) but was using
the 'local' keyword in the tryGetMetadata function, which is a bash-specific
feature. This caused shellcheck to fail with SC3043 warnings in CI.

Fixed by removing 'local' keywords from variable declarations in the
tryGetMetadata function. The variables are still function-scoped in practice
since they're assigned at the beginning of the function.

This resolves the CI failure introduced in PR #14788 (run #919).

* ci: Make ansible-lint stricter and fix basic issues

- Remove || true from ansible-lint CI job to enforce linting
- Enable name[play] rule - all plays should be named
- Enable yaml[new-line-at-end-of-file] rule
- Move name[missing] from skip_list to warn_list (first step)
- Add names to plays in main.yml and users.yml
- Document future linting improvements in comments

This makes the CI stricter while fixing the easy issues first.
More comprehensive fixes for the 113 name[missing] warnings can
be addressed in future PRs.

* fix: Add name[missing] to skip_list temporarily

The ansible-lint CI is failing because name[missing] was not properly
added to skip_list. This causes 113 name[missing] errors to fail the CI.

Adding it to skip_list for now to fix the CI. The rule can be moved to
warn_list and eventually enabled once all tasks are properly named in
future PRs.

* fix: Fix ansible-lint critical errors

- Fix schema[tasks] error in roles/local/tasks/prompts.yml by removing with_items loop
- Add missing newline at end of requirements.yml
- Replace ignore_errors with failed_when in reboot task
- Add pipefail to shell command with pipes in strongswan openssl task

These fixes address all critical ansible-lint errors that were causing CI failures.
2025-08-03 07:04:04 -04:00
Dan Guido
9a7a930895
fix: Add timeouts to curl commands in install.sh with retry logic (#14788)
Added configurable timeouts and retry logic to all curl commands in publicIpFromMetadata():
- --connect-timeout 5: 5 seconds to establish connection
- --max-time ${METADATA_TIMEOUT:-20}: Configurable timeout (default 20 seconds)
- Retry logic: Try up to 2 times with 2-second delay between attempts
- Environment variable: METADATA_TIMEOUT can override default timeout

This prevents the installation script from hanging indefinitely when:
- Metadata services are slow or unresponsive
- Network issues cause connections to stall
- Script is run in non-cloud environments where metadata IPs don't respond

The increased timeout (20s) and retry logic ensure compatibility with:
- Azure deployments in secondary regions (known to be slower)
- High-latency environments (satellite, rural connections)
- Corporate environments with proxies or deep packet inspection
- Temporary network glitches or cloud provider maintenance

The existing fallback to publicIpFromInterface() will handle cases where
metadata endpoints are unavailable after all retry attempts.

Fixes #14350

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Claude <noreply@anthropic.com>
2025-08-03 06:26:01 -04:00