From 2ccf720db227eab67121ff8ed512c62f34452d28 Mon Sep 17 00:00:00 2001 From: L3D Date: Thu, 2 Sep 2021 01:36:13 +0200 Subject: [PATCH] configure avahi variables --- README.md | 33 +++++++++++++++++++++++++++++++++ defaults/main.yml | 23 ++++++++++++++--------- meta/main.yml | 2 +- templates/avahi.service.j2 | 18 ++++++++++++------ vars/main.yml | 2 +- 5 files changed, 61 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index d9f6bb3..1b055b9 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,39 @@ =========================== Ansible role to install the avahi_daemon and optionally announce some services. + Variables +----------- +In the ``avahi_services`` variable you can define the services you want to announce. +Here is a list with available parameters: + + ``service``: Service Name *(HTTP/SSH/...)* ***(required)*** + + ``port``: Service Port ***(required)*** + - ``name``: optional name to announce the Service + - ``protocol``: ``any``/``ipv6``/``ipv4`` + - ``txt_records``: an array of txt records + + +Example: +```yaml +--- +avahi_services: + - service: 'SSH' + port: 22 + protocol: 'any' + - service: 'NFS' + name: 'Filesharing Host %h' + port: 2049 + protocol: 'ipv6' + txt_records: + - 'path=/path/to/nfsexport' + - service: 'FTP' + port: '21' + protocol: 'ipv4' + txt_records: + - 'path=/ftppath' + - 'u=ftpuser' + - 'p=ftppass' +``` + Netfilter rules --------------- Avahi is using multicast to announce services. diff --git a/defaults/main.yml b/defaults/main.yml index 37ce211..f2b4067 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -2,15 +2,20 @@ avahi_services: - service: 'SSH' port: 22 - # - service: 'NFS' - # port: 2049 - # extra: 'path=/path/to/nfsexport' - # - service: 'FTP' - # port: '21' - # extra: | - # path=/ftppath - # u=ftpuser - # p=ftppass + protocol: 'any' +# - service: 'NFS' +# name: 'Filesharing Host %h' +# port: 2049 +# protocol: 'ipv6' +# txt_records: +# - 'path=/path/to/nfsexport' +# - service: 'FTP' +# port: '21' +# protocol: 'ipv4' +# txt_records: +# - 'path=/ftppath' +# - 'u=ftpuser' +# - 'p=ftppass' # should we do a version check? (recomended) submodules_versioncheck: false diff --git a/meta/main.yml b/meta/main.yml index 614c943..d91ddae 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -16,6 +16,6 @@ galaxy_info: galaxy_tags: - avahi - daemon - - avahi_daemon - mdns + - bonjour dependencies: [] diff --git a/templates/avahi.service.j2 b/templates/avahi.service.j2 index c100334..07a4109 100644 --- a/templates/avahi.service.j2 +++ b/templates/avahi.service.j2 @@ -1,12 +1,18 @@ - {{ item.service | upper }} server at %h - + + {%- if item.name is defined -%} + {{- item.name -}} + {%- else -%} + {{ item.service | upper }} server at %h + {%- endif -%} + + _{{ item.service | lower }}._tcp - {{ item.port | string }} -{% if item.extra is defined %} - {{ item.extra }} -{% endif %} + {{ item.port | int }} +{% for record in item.txt_records | default([]) %} + {{ record }} +{% endfor %} diff --git a/vars/main.yml b/vars/main.yml index 0c4ea84..d102bfb 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,4 +1,4 @@ --- # versionscheck -playbook_version_number: 5 +playbook_version_number: 6 playbook_version_path: 'do1jlr.avahi_daemon.version'