--- - name: Configure avahi-daemon ini_file: path: '/etc/avahi/avahi-daemon.conf' no_extra_spaces: yes section: "{{ item.key.split('.',1)[0] }}" option: "{{ item.key.split('.',1)[1] }}" value: "{{ (item.value is string)|ternary(item.value,omit) }}" state: "{{ (item.value is string)|ternary('present','absent') }}" with_dict: 'server.host-name': '{{ hostname }}' 'server.domain-name': 'local' 'server.browse-domains': '' 'server.use-ipv4': 'yes' 'server.use-ipv6': 'yes' 'server.allow-interfaces': 'lan11,lan12,lan14' 'server.enable-dbus': 'yes' 'server.disallow-other-stacks': 'yes' 'wide-area.enable-wide-area': 'yes' 'publish.disable-publishing': 'no' 'publish.disable-user-service-publishing': 'no' 'publish.publish-addresses': 'yes' 'publish.publish-hinfo': 'yes' 'publish.publish-workstation': 'no' 'publish.publish-domain': 'yes' 'publish.publish-dns-servers': '185.38.175.0,2a01:4262:1ab::' 'publish.publish-resolv-conf-dns-servers': 'no' 'reflector.enable-reflector': 'yes' notify: - restart avahi-daemon - name: Configure hosts template: dest: '/etc/avahi/hosts' src: avahi-hosts.j2 owner: root group: root mode: 0644 notify: - restart avahi-daemon - name: Enable avahi-daemon service systemd: name: avahi-daemon.service enabled: yes masked: no state: started when: not chroot - name: '- when in chroot' command: systemctl enable avahi-daemon.service args: creates: '/etc/systemd/system/multi-user.target.wants/avahi-daemon.service' when: chroot|bool - name: Use nss-mdns lineinfile: path: '/etc/nsswitch.conf' regexp: '^hosts:' line: 'hosts: files myhostname mdns_minimal [NOTFOUND=return] dns' # vim: set ts=2 sw=2 et: