fix(private_routing): add DNS nameservers to Netplan/networkd route config
OpenVPN Ansible / Ansible Syntax Check (push) Successful in 9s
OpenVPN Ansible / Ansible Lint (push) Successful in 18s
OpenVPN Ansible / Deploy VPN Networking and OpenVPN (push) Successful in 1m54s
OpenVPN Ansible / Generate SBOM (push) Successful in 54s
OpenVPN Ansible / Scan SBOM with Trivy (push) Successful in 18s
OpenVPN Ansible / Ansible Syntax Check (push) Successful in 9s
OpenVPN Ansible / Ansible Lint (push) Successful in 18s
OpenVPN Ansible / Deploy VPN Networking and OpenVPN (push) Successful in 1m54s
OpenVPN Ansible / Generate SBOM (push) Successful in 54s
OpenVPN Ansible / Scan SBOM with Trivy (push) Successful in 18s
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user