1
0
Fork 0
mirror of https://github.com/roles-ansible/ansible_role_avahi_daemon.git synced 2024-08-16 15:09:48 +02:00

Announce first avahi service

This commit is contained in:
L3D 2021-09-02 00:24:53 +02:00
parent 53e9407c56
commit a8c2df8169
Signed by: l3d
GPG key ID: CD08445BFF4313D1
7 changed files with 74 additions and 7 deletions

View file

@ -1,2 +1,27 @@
# ansible_role_template
Template for Ansible roles
Netfilter rules
---------------
Do not forget to add netfilter rules for multicast dns.
Configuration example for `ferm`:
```
# mdns
daddr 224.0.0.251 proto udp dport 5353 ACCEPT;
daddr ff02::fb proto udp dport 5353 ACCEPT;
```
Links
-----
* http://dns-sd.org/
* http://www.multicastdns.org/
* https://www.avahi.org/
* https://github.com/lathiat/avahi
* http://www.dns-sd.org/ServiceTypes.html

View file

@ -1,10 +1,16 @@
---
avahi_packages:
- 'avahi-daemon'
- 'avahi-utils'
#- 'avahi-discover'
#- 'mdns-scan'
avahi_services:
- service: 'SSH'
port: 22
# - service: 'NFS'
# port: 2049
# extra: '<txt-record>path=/path/to/nfsexport</txt-record>'
# - service: 'FTP'
# port: '21'
# extra: |
# <txt-record>path=/ftppath</txt-record>
# <txt-record>u=ftpuser</txt-record>
# <txt-record>p=ftppass</txt-record>
# should we do a version check? (recomended)
submodules_versioncheck: false

6
handlers/main.yml Normal file
View file

@ -0,0 +1,6 @@
---
- name: systemctl restart avahi-daemon.service
become: true
ansible.builtin.systemd:
name: avahi-daemon.service
state: restarted

11
tasks/avahi-services.yml Normal file
View file

@ -0,0 +1,11 @@
---
- name: Copy configured avahi services
ansible.builtin.template:
src: 'templates/avahi.service.j2'
dest: "/etc/avahi/services/{{ item.service | lower }}.service"
owner: root
group: root
mode: 'u=rw,g=r,o=r'
notify:
- systemctl restart avahi-daemon.service
with_items: "{{ avahi_services }}"

View file

@ -11,3 +11,10 @@
- name: install avahi requirements
ansible.builtin.include_tasks: install.yml
- debug:
msg: "{{ item }}"
with_items: "{{ avahi_services }}"
- name: optionally announce avahi services
ansible.builtin.include_tasks: avahi-services.yml

View file

@ -0,0 +1,12 @@
<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
<name replace-wildcards="yes">{{ item.service | upper }} server at %h</name>
<service>
<type>_{{ item.service | lower }}._tcp</type>
<port>{{ item.port | string }}</port>
{% if item.extra is defined %}
{{ item.extra }}
{% endif %}
</service>
</service-group>

View file

@ -1,4 +1,4 @@
---
# versionscheck
playbook_version_number: 3
playbook_version_number: 4
playbook_version_path: 'do1jlr.avahi_daemon.version'