Added optional admin-local DNS bypass.
authorLuke Hoersten <luke@hoersten.org>
Sun, 21 Jan 2024 15:58:58 -0600
changeset 226 ce33bf94045f
parent 225 6936497313ac
child 227 2e0366f2dcbe
Added optional admin-local DNS bypass.
adguard-home/defaults/main.yaml
adguard-home/tasks/disable-dns-bypass.yaml
adguard-home/tasks/enable-dns-bypass.yaml
adguard-home/tasks/main.yaml
--- a/adguard-home/defaults/main.yaml	Thu Jan 18 16:04:11 2024 -0600
+++ b/adguard-home/defaults/main.yaml	Sun Jan 21 15:58:58 2024 -0600
@@ -1,5 +1,6 @@
 ---
 
+adguard_dns_bypass: true
 adguard_home_port: "80"
 adguard_home_arch: "arm"
 adguard_home_tar: "https://static.adguard.com/adguardhome/release/AdGuardHome_linux_{{adguard_home_arch}}.tar.gz"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/adguard-home/tasks/disable-dns-bypass.yaml	Sun Jan 21 15:58:58 2024 -0600
@@ -0,0 +1,24 @@
+---
+
+- name: check if resolv.conf exists
+  stat: path="/etc/resolv.conf"
+  register: sym
+
+- name: replace systemd-resolved conf stub
+  become: yes
+  copy:
+    remote_src: yes
+    src:  "/run/systemd/resolve/resolv.conf"
+    dest: "/etc/resolv.conf"
+  when: sym.stat.islnk is defined and sym.stat.islnk
+
+- name: ensure nameserver is self
+  become: yes
+  lineinfile:
+    path: "/etc/resolv.conf"
+    regexp: "^nameserver"
+    line: "nameserver {{ansible_default_ipv4.address}}"
+
+- name: disable systemd-resolved service
+  become: yes
+  systemd: name="systemd-resolved.service" enabled="no" state="stopped"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/adguard-home/tasks/enable-dns-bypass.yaml	Sun Jan 21 15:58:58 2024 -0600
@@ -0,0 +1,17 @@
+---
+
+- name: check if resolv.conf exists
+  stat: path="/etc/resolv.conf"
+  register: sym
+
+- name: replace systemd-resolved conf link
+  become: yes
+  file:
+    src:  "../run/systemd/resolve/stub-resolv.conf"
+    dest: "/etc/resolv.conf"
+    state: "link"
+  when: sym.stat.islnk is defined and not sym.stat.islnk
+
+- name: enable systemd-resolved service
+  become: yes
+  systemd: name="systemd-resolved.service" enabled="yes" state="started"
--- a/adguard-home/tasks/main.yaml	Thu Jan 18 16:04:11 2024 -0600
+++ b/adguard-home/tasks/main.yaml	Sun Jan 21 15:58:58 2024 -0600
@@ -44,28 +44,11 @@
   template: src="AdGuardHome.yaml.j2" dest="/etc/AdGuardHome/AdGuardHome.yaml"
   notify: restart adguard home
 
-- name: check if resolv.conf exists
-  stat: path="/etc/resolv.conf"
-  register: sym
+- include: enable-dns-bypass.yaml
+  when: adguard_dns_bypass
 
-- name: replace systemd-resolved conf stub
-  become: yes
-  copy:
-    remote_src: yes
-    src:  "/run/systemd/resolve/resolv.conf"
-    dest: "/etc/resolv.conf"
-  when: sym.stat.islnk is defined and sym.stat.islnk
-
-- name: ensure nameserver is self
-  become: yes
-  lineinfile:
-    path: "/etc/resolv.conf"
-    regexp: "^nameserver"
-    line: "nameserver {{ansible_default_ipv4.address}}"
-
-- name: disable systemd-resolved service
-  become: yes
-  systemd: name="systemd-resolved.service" enabled="no" state="stopped"
+- include: disable-dns-bypass.yaml
+  when: not adguard_dns_bypass
 
 - name: ensure adguard home is started
   become: yes