feat(ansible): automate NAT gateway and VPN routing
OpenVPN Ansible / Ansible Syntax Check (push) Successful in 11s
OpenVPN Ansible / Ansible Lint (push) Successful in 19s
OpenVPN Ansible / Deploy VPN Networking and OpenVPN (push) Failing after 1m27s
OpenVPN Ansible / Generate SBOM (push) Skipped
OpenVPN Ansible / Scan SBOM with Trivy (push) Skipped
OpenVPN Ansible / Ansible Syntax Check (push) Successful in 11s
OpenVPN Ansible / Ansible Lint (push) Successful in 19s
OpenVPN Ansible / Deploy VPN Networking and OpenVPN (push) Failing after 1m27s
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.
This commit is contained in:
@@ -24,3 +24,68 @@ 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.
|
||||
|
||||
Reference in New Issue
Block a user