mirror of
https://github.com/trailofbits/algo.git
synced 2026-08-24 08:32:29 +02:00
* Fix Ansible 12 double-templating and Jinja2 spacing issues This PR fixes critical deployment issues and improves code consistency for Ansible 12 compatibility. ## Fixed Issues ### 1. Double-templating bug (Issue #14835) Fixed 7 instances of invalid double-templating that breaks deployments: - Changed `{{ lookup('file', '{{ var }}') }}` to `{{ lookup('file', var) }}` - Affects Azure, DigitalOcean, GCE, Linode, and IPsec configurations - Added comprehensive test to prevent regression ### 2. Jinja2 spacing inconsistencies Fixed 33+ spacing issues for better code quality: - Removed spaces between Jinja2 blocks: `}} {%` → `}}{%` - Fixed operator spacing: `int -1` → `int - 1` - Fixed filter spacing: `|b64encode` → `| b64encode` - Consolidated multiline expressions to single lines ### 3. Test suite improvements Enhanced boolean type checking test to be more targeted: - Excludes external dependencies and CloudFormation templates - Only tests Algo's actual codebase - Verified with mutation testing - Added comprehensive documentation ## Testing - All 87 unit tests pass - 0 Jinja2 spacing issues remaining (verified by ansible-lint) - Ansible syntax checks pass for all playbooks - Mutation testing confirms tests catch real issues 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Fix Python linting issue - Remove unnecessary f-string prefix where no placeholders are used - Fixes ruff F541 error * Fix line length linting issues - Break long lines to stay within 120 character limit - Extract variables for better readability - Fixes ruff E501 errors --------- Co-authored-by: Claude <noreply@anthropic.com>
59 lines
2.2 KiB
YAML
59 lines
2.2 KiB
YAML
---
|
|
- name: Build python virtual environment
|
|
import_tasks: venv.yml
|
|
|
|
- name: Include prompts
|
|
import_tasks: prompts.yml
|
|
|
|
- block:
|
|
- set_fact:
|
|
algo_region: >-
|
|
{%- if region is defined -%}{{ region }}{%- elif _algo_region.user_input is defined and _algo_region.user_input | length > 0 -%}{{ cs_zones[_algo_region.user_input | int - 1]['name'] }}{%- else -%}{{ cs_zones[default_zone | int - 1]['name'] }}{%- endif -%}
|
|
|
|
- name: Security group created
|
|
cs_securitygroup:
|
|
name: "{{ algo_server_name }}-security_group"
|
|
description: AlgoVPN security group
|
|
register: cs_security_group
|
|
|
|
- name: Security rules created
|
|
cs_securitygroup_rule:
|
|
security_group: "{{ cs_security_group.name }}"
|
|
protocol: "{{ item.proto }}"
|
|
start_port: "{{ item.start_port }}"
|
|
end_port: "{{ item.end_port }}"
|
|
cidr: "{{ item.range }}"
|
|
with_items:
|
|
- { proto: tcp, start_port: "{{ ssh_port }}", end_port: "{{ ssh_port }}", range: 0.0.0.0/0 }
|
|
- { proto: udp, start_port: 4500, end_port: 4500, range: 0.0.0.0/0 }
|
|
- { proto: udp, start_port: 500, end_port: 500, range: 0.0.0.0/0 }
|
|
- { proto: udp, start_port: "{{ wireguard_port }}", end_port: "{{ wireguard_port }}", range: 0.0.0.0/0 }
|
|
|
|
- name: Set facts
|
|
set_fact:
|
|
image_id: "{{ cloud_providers.cloudstack.image }}"
|
|
size: "{{ cloud_providers.cloudstack.size }}"
|
|
disk: "{{ cloud_providers.cloudstack.disk }}"
|
|
|
|
- name: Server created
|
|
cs_instance:
|
|
name: "{{ algo_server_name }}"
|
|
root_disk_size: "{{ disk }}"
|
|
template: "{{ image_id }}"
|
|
security_groups: "{{ cs_security_group.name }}"
|
|
zone: "{{ algo_region }}"
|
|
service_offering: "{{ size }}"
|
|
user_data: "{{ lookup('template', 'files/cloud-init/base.yml') }}"
|
|
register: cs_server
|
|
|
|
- set_fact:
|
|
cloud_instance_ip: "{{ cs_server.default_ip }}"
|
|
ansible_ssh_user: algo
|
|
ansible_ssh_port: "{{ ssh_port }}"
|
|
cloudinit: true
|
|
environment:
|
|
CLOUDSTACK_KEY: "{{ algo_cs_key }}"
|
|
CLOUDSTACK_SECRET: "{{ algo_cs_token }}"
|
|
CLOUDSTACK_ENDPOINT: "{{ algo_cs_url }}"
|
|
no_log: true
|