ansible rework

This commit is contained in:
Sergei Poljanski 2025-11-04 11:06:35 +02:00
commit eecff4345a
47 changed files with 1995 additions and 538 deletions

View file

@ -1,4 +1,7 @@
---
- name: Validate WireGuard variables
ansible.builtin.import_tasks: validate.yaml
- name: Install WireGuard
ansible.builtin.apt:
name:

View file

@ -0,0 +1,19 @@
---
# Variable validation for wireguard role
- name: Validate WireGuard required variables
ansible.builtin.assert:
that:
- wireguard_network is defined
- wireguard_network | length > 0
- wireguard_port is defined
- wireguard_port | int > 0
- wireguard_port | int < 65536
- wireguard_interface is defined
- wireguard_interface | length > 0
fail_msg: |
WireGuard role requires:
- wireguard_network (CIDR notation, e.g., 10.20.0.0/24)
- wireguard_port (1-65535)
- wireguard_interface (e.g., wg0)
success_msg: "WireGuard variables validated successfully"

View file

@ -14,7 +14,7 @@ PublicKey = {{ wireguard_server_public_key }}
{% if item.preshared_key %}
PresharedKey = {{ item.preshared_key }}
{% endif %}
Endpoint = {{ ansible_host }}:{{ wireguard_port }}
Endpoint = {{ public_ip }}:{{ wireguard_port }}
# Allow all VPN traffic (peer-to-peer connectivity)
AllowedIPs = {{ wireguard_ipv4_network }},{{ wireguard_ipv6_network }}{% if wireguard_additional_routes | length > 0 %},{{ wireguard_additional_routes | join(',') }}{% endif %}