brianhartsock.avahi
ansible.avahi
This is an Ansible role to install and set up Avahi, which helps devices in a network find each other automatically, similar to how Apple Bonjour works. This allows Macs to discover services running on Linux machines.
Requirements
This role has been tested on Ubuntu 20.04 and should work on most recent Debian systems.
You'll need sudo
access to run this role, so use become: True
or a user with the right permissions to install and configure packages.
Role Variables
You can customize Avahi services using the following variables defined in defaults/main.yml
. The most important variable is avahi_services
, which specifies the services you want to share via mDNS.
# List of service definitions.
avahi_services:
# The file location, /etc/avahi/services/afpd.service
- name: afpd
# List of services
services:
# Service type, port, and additional info.
- type: _afpower._tcp
port: 548
- type: _device-info._tcp
port: 0
txt_records:
- model=Xserve
# Replace wildcards in service definitions (e.g., %h -> hostname)
avahi_replace_wildcards: yes
# Name of the network to advertise
avahi_network_name: '%h'
# Enable or disable IPv6
avahi_use_ipv6: 'no'
# Specify which network interfaces to use
avahi_allow_interfaces: "{{ ansible_default_ipv4.interface }}"
# Enable or disable reflector mode
avahi_enable_reflector: 'yes'
# Support for systems that don't use dbus/systemd
avahi_enable_dbus: 'yes'
Dependencies
None
Example Playbook
Here’s an example of how to use this role, including how to pass in variables:
- hosts: servers
roles:
- name: brianhartsock.avahi
become: true
License
MIT
Author Information
Created with care by Brian Hartsock.
Helpful Links
ansible-galaxy install brianhartsock.avahi