diff --git a/README.md b/README.md index 3675de6..69cbfe4 100644 --- a/README.md +++ b/README.md @@ -7,18 +7,37 @@ Avahi provides local hostname resolution using a "hostname.local" naming scheme. This ansible role installs the required dependencies and configures the DNS resolver accordingly. -You can opt-out from deploying a new ``/etc/nsswitch.conf`` config by setting ``avahi__configure_nsswitch`` to ``false``. +You can opt-out from deploying a new ``/etc/nsswitch.conf`` config by setting ``avahi_client__configure_nsswitch`` to ``false``. You can opt-in in a simple versionscheck that can prevent you from running a older version of this role by setting ``submodules_versioncheck`` to ``true``. + +Configuring nsswitch +-------------------- + If you want only IPv4 or IPv6 names resolved, change ``mdns`` to ``mdns4`` or ``mdns6`` in these variables: + ```yaml -avahi__mdns_name: 'mdns' -avahi__mdns_minimal_name: 'mdns_minimal' +avahi_client__mdns_name: 'mdns' +avahi_client__mdns_minimal_name: 'mdns_minimal' ``` - Learn more ------------- -+ [/etc/nsswitch.conf](https://man7.org/linux/man-pages/man5/nsswitch.conf.5.html) -+ Avahi [wiki.archlinux.org](https://wiki.archlinux.org/title/Avahi) -+ nss-mdns [0pointer.de](https://0pointer.de/lennart/projects/nss-mdns/#documentation) +From the documentation of [nss-mdns](https://github.com/lathiat/nss-mdns) + +> `mdns` resolves both IPv6 and IPv4 addresses, `mdns4` only IPv4 addresses and `mdns6` only IPv6 addresses. +> `mdns{4,6,}_minimal` is mostly identical to the versions without `_minimal`. However, they differ in one way. The minimal versions will always deny to resolve host names that don't end in `.local` or addresses that aren't in the range `169.254.x.x` (the range used by IPV4LL/APIPA/RFC3927.) +> Combining the `_minimal` and the normal NSS modules allows us to make mDNS authoritative for Zeroconf host names and addresses and use it as fallback for everything else. + + +Learn more +---------- + +* DNS-SD [http://dns-sd.org/](http://dns-sd.org/) +* mDNS [http://www.multicastdns.org/](http://www.multicastdns.org/) + +* Avahi [https://www.avahi.org/](https://www.avahi.org/) +* Avahi git [https://github.com/lathiat/avahi](https://github.com/lathiat/avahi) +* Avahi [wiki.archlinux.org](https://wiki.archlinux.org/title/Avahi) + +* [NSS mdns plugin](https://github.com/lathiat/nss-mdns) +* [/etc/nsswitch.conf](https://manpages.debian.org/unstable/manpages/nsswitch.conf.5.en.html) diff --git a/defaults/main.yml b/defaults/main.yml index 630d7a2..ebedf51 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,10 +1,10 @@ --- # deploy custom /etc/nsswitch.conf config -avahi__configure_nsswitch: true +avahi_client__configure_nsswitch: true # mdns resolver name -avahi__mdns_name: 'mdns' -avahi__mdns_minimal_name: 'mdns_minimal' +avahi_client__mdns_name: 'mdns' +avahi_client__mdns_minimal_name: 'mdns_minimal' # should we do a version check? (recomended) submodules_versioncheck: false diff --git a/tasks/install.yml b/tasks/install.yml index 189369a..6898f1a 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -7,8 +7,8 @@ when: - ansible_pkg_mgr == "apt" -- name: install avahi packages +- name: Install Avahi packages become: true ansible.builtin.package: - name: "{{ avahi_packages }}" + name: "{{ avahi_client__packages }}" state: present diff --git a/tasks/main.yml b/tasks/main.yml index c381ffe..12caf5c 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -14,4 +14,4 @@ - name: configure /etc/nsswitch.conf ansible.builtin.include_tasks: nsswitch.yml - when: avahi__configure_nsswitch | bool + when: avahi_client__configure_nsswitch | bool diff --git a/tasks/nsswitch.yml b/tasks/nsswitch.yml index 5981771..5ca6336 100644 --- a/tasks/nsswitch.yml +++ b/tasks/nsswitch.yml @@ -1,5 +1,5 @@ --- -- name: deploy /etc/nsswitch.conf +- name: Deploy '/etc/nsswitch.conf' become: true ansible.builtin.template: src: 'templates/nsswitch.conf.j2' diff --git a/templates/nsswitch.conf.j2 b/templates/nsswitch.conf.j2 index f1bfdbd..64621b0 100644 --- a/templates/nsswitch.conf.j2 +++ b/templates/nsswitch.conf.j2 @@ -12,7 +12,7 @@ gshadow: files publickey: files -hosts: files mymachines myhostname {{ avahi__mdns_minimal_name }} [NOTFOUND=return] resolve [!UNAVAIL=return] dns {{ avahi__mdns_name }} +hosts: files {{ avahi_client__mdns_minimal_name }} [NOTFOUND=return] resolve [!UNAVAIL=return] dns {{ avahi_client__mdns_name }} myhostname networks: files protocols: db [NOTFOUND=return] files diff --git a/vars/Archlinux.yml b/vars/Archlinux.yml index a884c8e..dc1a30b 100644 --- a/vars/Archlinux.yml +++ b/vars/Archlinux.yml @@ -1,5 +1,5 @@ --- -avahi_packages: - - avahi - - mdns-scan - - nss-mdns +avahi_client__packages: + - 'avahi' + - 'nss-mdns' +# - 'mdns-scan' diff --git a/vars/Debian.yml b/vars/Debian.yml index 791e317..ef2da94 100644 --- a/vars/Debian.yml +++ b/vars/Debian.yml @@ -1,5 +1,8 @@ --- -avahi_packages: +avahi_client__packages: - 'avahi-discover' - 'avahi-utils' - - 'mdns-scan' + - 'libnss-mdns' +# - 'avahi-autoipd' +# - 'avahi-dnsconfd' +# - 'mdns-scan' diff --git a/vars/main.yml b/vars/main.yml index 15c4f74..7d3480a 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,4 +1,4 @@ --- # versionscheck -playbook_version_number: 6 +playbook_version_number: 7 playbook_version_path: 'do1jlr.avahi_client.version' diff --git a/vars/os_fallback.yml b/vars/os_fallback.yml index 4b6d3e0..459cbb8 100644 --- a/vars/os_fallback.yml +++ b/vars/os_fallback.yml @@ -1,3 +1,4 @@ --- -avahi_packages: - - mdns-scan +avahi_client__packages: + - avahi +# - 'mdns-scan'