From 8f69c9d973728d3a2bad41cd83de9f854379bcf4 Mon Sep 17 00:00:00 2001 From: Jared Hampson Date: Sun, 28 Jul 2024 20:50:01 -0500 Subject: [PATCH] feat(supervised_install): add workaround for broken dns A new variable `supervised_install_resolve_conf_overrides` can be used to configure resolve.conf overrides if the supervisor's default configuration breaks DNS resolution. ref: https://github.com/home-assistant/supervised-installer/issues/339 --- roles/supervised_install/README.md | 11 +++++++++++ roles/supervised_install/tasks/main.yml | 24 ++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/roles/supervised_install/README.md b/roles/supervised_install/README.md index f49e8df..87d1795 100644 --- a/roles/supervised_install/README.md +++ b/roles/supervised_install/README.md @@ -16,6 +16,17 @@ OS Packages: Role Variables -------------- +Optional variables with example configurations + +```yaml +# Used to create overrides for resolve.conf to fix DNS resolution +# If not set, then no resolve.conf overrides will be created +# ref: https://github.com/home-assistant/supervised-installer/issues/339 +supervised_install_resolve_conf_overrides: | + DNS=192.168.68.1 + DNSStubListener=no +``` + Variables used from fact gathering - ansible_pkg_mgr: Used to validate that apt is available, since it is used by this role to install OS packages diff --git a/roles/supervised_install/tasks/main.yml b/roles/supervised_install/tasks/main.yml index d3f0ddc..bbce5c4 100644 --- a/roles/supervised_install/tasks/main.yml +++ b/roles/supervised_install/tasks/main.yml @@ -59,6 +59,30 @@ regex: 'precedence ::ffff:0:0/96 100' line: 'precedence ::ffff:0:0/96 100' +- name: Configure DNS resolution + block: + - name: Create resolve.conf drop in directory + ansible.builtin.file: + path: /etc/systemd/resolve.conf.d + state: directory + mode: 0755 + + - name: Create resolve.conf override config + ansible.builtin.copy: + content: | + [Resolve] + {{ supervised_install_resolve_conf_overrides }} + dest: /etc/systemd/resolve.conf.d/resolve.conf + mode: 0644 + register: resolve_conf_override_result + + - name: Restart systemd-resolved + ansible.builtin.service: + name: systemd-resolved + state: restarted + when: resolve_conf_override_result is changed + when: supervised_install_resolve_conf_overrides is defined + - name: Get download url for latest os-agent .deb release shell: | curl -s https://api.github.com/repos/home-assistant/os-agent/releases/latest \