OpenVPN Ansible / Ansible Syntax Check (push) Successful in 11s
OpenVPN Ansible / Ansible Lint (push) Successful in 18s
OpenVPN Ansible / Deploy VPN Networking and OpenVPN (push) Failing after 1m25s
OpenVPN Ansible / Generate SBOM (push) Skipped
OpenVPN Ansible / Scan SBOM with Trivy (push) Skipped
- Add NAT gateway inventory and routing playbooks. - Update Gitea Actions and GitLab CI to validate all playbooks. - Deploy gateway and routing configurations before OpenVPN. - Document setup and verification steps.
92 lines
3.7 KiB
Markdown
92 lines
3.7 KiB
Markdown
# VPN node configuration
|
|
|
|
Ansible configuration for Ubuntu 24.04 VPN nodes. Host packages are installed
|
|
through Ubuntu's package manager, so package architecture selection is
|
|
automatic.
|
|
|
|
## Supported platforms
|
|
|
|
- `linux/amd64` (`x86_64`)
|
|
- `linux/arm64` (`aarch64`)
|
|
|
|
The common role checks the Ubuntu release and architecture before
|
|
making changes. Networking sysctl configuration uses the interfaces reported
|
|
by Ansible rather than assuming a particular NIC name. The OpenVPN RADIUS
|
|
plugin path is discovered after package installation, including Debian's
|
|
architecture-specific library directories.
|
|
|
|
## Run
|
|
|
|
Configure inventory in `inventories/prod/hosts.ini`, then run:
|
|
|
|
```sh
|
|
ansible-playbook playbooks/openvpn.yml
|
|
```
|
|
|
|
The target hosts must run Ubuntu 24.04 and Ansible must gather facts.
|
|
|
|
## Private VM internet access
|
|
|
|
The `vpn-gateway` VM provides NAT for private VPN nodes. A private VM sends
|
|
internet-bound traffic to the Hetzner private-network router (`10.0.0.1`). The
|
|
Hetzner network route for `0.0.0.0/0` then delivers it to the gateway's private
|
|
address (`10.100.0.4`), where iptables masquerades it out `eth0`. The route in
|
|
Hetzner's network and the operating-system default route on each private VM are
|
|
separate settings: both must exist. The gateway itself keeps its public default
|
|
route through `eth0`.
|
|
|
|
`vpn_nodes` contains private VPN nodes and `nat_gateways` contains only the
|
|
gateway. Add new private VMs to `vpn_nodes` with their management address and
|
|
private address, and set the private routing role variables in host/group vars
|
|
if their interface or gateway differs. Do not add a gateway to `vpn_nodes`.
|
|
The routing role detects Netplan or systemd-networkd and adds only a route
|
|
fragment; review the host's existing route metrics and manager before rollout.
|
|
The Netplan fragment adds a metric 100 default route. Internal destinations
|
|
continue to use more-specific routes; validate the FreeRADIUS NodePort path on
|
|
each host.
|
|
|
|
Install required collections with `ansible-galaxy collection install -r
|
|
requirements.yml`, then check syntax and deploy independently:
|
|
|
|
```sh
|
|
ansible-playbook --syntax-check playbooks/nat-gateway.yml
|
|
ansible-playbook --syntax-check playbooks/private-vpn-routing.yml
|
|
ansible-playbook --check playbooks/nat-gateway.yml --limit nat_gateways
|
|
ansible-playbook playbooks/nat-gateway.yml --limit nat_gateways
|
|
ansible-playbook --check playbooks/private-vpn-routing.yml --limit vpn_nodes
|
|
ansible-playbook playbooks/private-vpn-routing.yml --limit vpn_nodes
|
|
```
|
|
|
|
Check mode cannot validate actual kernel routes or persistence and may report
|
|
handlers without applying them. `netplan apply` and restarting
|
|
systemd-networkd can briefly interrupt remote connectivity; schedule route
|
|
rollout with console access or a maintenance window. Do not reboot automatically.
|
|
|
|
Verify the gateway after deployment (and separately after a planned reboot):
|
|
|
|
```sh
|
|
sysctl net.ipv4.ip_forward
|
|
iptables -t nat -S POSTROUTING
|
|
iptables -S FORWARD
|
|
systemctl is-enabled nat-gateway-firewall.service
|
|
systemctl status nat-gateway-firewall.service --no-pager
|
|
ip -4 route show default
|
|
```
|
|
|
|
Expect forwarding value `1`, the subnet-specific MASQUERADE and two narrow
|
|
FORWARD rules, an enabled firewall persistence service, and the gateway public
|
|
default via `eth0`. The service re-adds only these scoped rules at boot and
|
|
does not save or flush the full firewall ruleset. On each private VM:
|
|
|
|
```sh
|
|
ip -4 route show default
|
|
ip -4 route get 8.8.8.8
|
|
getent hosts google.com
|
|
curl -I --max-time 10 https://google.com
|
|
```
|
|
|
|
Also connect to the existing FreeRADIUS NodePort endpoint using its configured
|
|
address and port. DNS and NodePort checks require live network access. The
|
|
inventory gateway IP/interface values are taken from the supplied task; verify
|
|
them against the live Hetzner VM before applying.
|