Skip to content

Commit

Permalink
feat(supervised_install): add workaround for broken dns
Browse files Browse the repository at this point in the history
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: home-assistant/supervised-installer#339
  • Loading branch information
jhampson-dbre committed Jul 29, 2024
1 parent 7c25d19 commit 8f69c9d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
11 changes: 11 additions & 0 deletions roles/supervised_install/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 24 additions & 0 deletions roles/supervised_install/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down

0 comments on commit 8f69c9d

Please sign in to comment.