fix(private_routing): add DNS nameservers to Netplan/networkd route config
OpenVPN Ansible / Ansible Syntax Check (push) Successful in 11s
OpenVPN Ansible / Ansible Lint (push) Failing after 17s
OpenVPN Ansible / Deploy VPN Networking and OpenVPN (push) Skipped
OpenVPN Ansible / Generate SBOM (push) Skipped
OpenVPN Ansible / Scan SBOM with Trivy (push) Skipped

This commit is contained in:
2026-10-29 11:48:46 +01:00
parent 86c47eec4f
commit 30f2fb0635
2 changed files with 22 additions and 1 deletions
+3
View File
@@ -2,3 +2,6 @@
private_routing_interface: enp7s0
private_routing_gateway: 10.0.0.1
private_routing_metric: 100
private_routing_nameservers:
- 1.1.1.1
- 9.9.9.9
+19 -1
View File
@@ -23,6 +23,7 @@
No Netplan configuration or active systemd-networkd interface found for
{{ private_routing_interface }}; refusing to change network configuration.
# ---- Netplan path ----
- name: Install Netplan route drop-in
ansible.builtin.copy:
dest: /etc/netplan/99-private-vpn-default-route.yaml
@@ -32,9 +33,11 @@
ethernets:
{{ private_routing_interface }}:
routes:
- to: 0.0.0.0/0
- to: default
via: {{ private_routing_gateway }}
metric: {{ private_routing_metric }}
nameservers:
addresses: {{ private_routing_nameservers | to_json }}
owner: root
group: root
mode: "0600"
@@ -46,6 +49,7 @@
changed_when: false
when: private_routing_netplan_files.matched | default(0) > 0
# ---- systemd-networkd path ----
- name: Install systemd-networkd route drop-in
ansible.builtin.copy:
dest: "/etc/systemd/network/90-{{ private_routing_interface }}-private-vpn-route.network"
@@ -53,6 +57,11 @@
[Match]
Name={{ private_routing_interface }}
[Network]
{% for ns in private_routing_nameservers %}
DNS={{ ns }}
{% endfor %}
[Route]
Destination=0.0.0.0/0
Gateway={{ private_routing_gateway }}
@@ -68,8 +77,17 @@
state: restarted
when: private_routing_netplan_files.matched | default(0) == 0
# ---- Verification (both paths) ----
- name: Verify selected route to internet
ansible.builtin.command: ip -4 route get 8.8.8.8
register: private_route_get
changed_when: false
failed_when: private_routing_gateway not in private_route_get.stdout or private_routing_interface not in private_route_get.stdout
- name: Verify DNS resolution through the gateway
ansible.builtin.command: getent hosts archive.ubuntu.com
register: private_dns_check
changed_when: false
retries: 5
delay: 3
until: private_dns_check.rc == 0