--- - name: Configure DNS for Incus Network hosts: localhost become: yes vars: incus_dns_ip: "{{ lookup('pipe', \"ip -4 -o addr show incusbr0 | awk '{print $4}' | cut -d/ -f1\") }}" resolved_conf_path: "/etc/systemd/resolved.conf.d/incus.conf" tasks: - name: Ensure systemd-resolved package is installed apt: name: systemd-resolved state: present update_cache: yes - name: Ensure systemd-resolved override directory exists file: path: "/etc/systemd/resolved.conf.d" state: directory owner: root group: root mode: '0755' - name: Write systemd-resolved DNS override for Incus copy: dest: "{{ resolved_conf_path }}" owner: root group: root mode: '0644' content: | [Resolve] DNS={{ incus_dns_ip }} 1.1.1.1 8.8.8.8 Domains=~incus - name: Enable systemd-resolved service systemd: name: systemd-resolved enabled: yes - name: Start systemd-resolved service systemd: name: systemd-resolved state: started - name: Ensure /etc/resolv.conf points to systemd-resolved file: src: /run/systemd/resolve/resolv.conf dest: /etc/resolv.conf state: link force: yes - name: Restart systemd-resolved to apply DNS changes systemd: name: systemd-resolved state: restarted - name: Inform user debug: msg: "DNS now points to {{ incus_dns_ip }}. systemd-resolved is active with ~incus search domain."