adguard-home/tasks/disable-dns-bypass.yaml
author Luke Hoersten <luke@hoersten.org>
Sun, 21 Jan 2024 15:58:58 -0600
changeset 226 ce33bf94045f
permissions -rw-r--r--
Added optional admin-local DNS bypass.

---

- 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"