From 61d0d56c428dfa75ccfa67252398d44e27b18f8a Mon Sep 17 00:00:00 2001 From: Bertrand Benjamin Date: Sun, 5 Jun 2022 09:05:48 +0200 Subject: [PATCH] Feat: add minidlna to nas --- home.yml | 4 + roles/minidlna/defaults/main.yml | 14 +++ roles/minidlna/handlers/main.yml | 6 + roles/minidlna/tasks/debian.yml | 6 + roles/minidlna/tasks/main.yml | 20 ++++ roles/minidlna/templates/minidlna.j2.conf | 132 ++++++++++++++++++++++ vars/home.yml | 9 +- vars/nas.yml | 4 + 8 files changed, 190 insertions(+), 5 deletions(-) create mode 100644 roles/minidlna/defaults/main.yml create mode 100644 roles/minidlna/handlers/main.yml create mode 100644 roles/minidlna/tasks/debian.yml create mode 100644 roles/minidlna/tasks/main.yml create mode 100644 roles/minidlna/templates/minidlna.j2.conf diff --git a/home.yml b/home.yml index 8d64798..6092a2c 100644 --- a/home.yml +++ b/home.yml @@ -41,6 +41,10 @@ - docker - pihole + - role: minidlna + tags: + - minidlna + tasks: - name: Include user include_role: diff --git a/roles/minidlna/defaults/main.yml b/roles/minidlna/defaults/main.yml new file mode 100644 index 0000000..c2ee82d --- /dev/null +++ b/roles/minidlna/defaults/main.yml @@ -0,0 +1,14 @@ +--- +# defaults file for minidlna +minidlna_network_interface: eth0 +minidlna_network_port: 8200 + +minidlna_friendly_name: Ansible DLNA server + +minidlna_media_dir: /var/lib/minidlna +minidlna_db_dir: /var/cache/minidlna +minidlna_log_dir: /var/cache/minidlna + +minidlna_root_container: "." + +minidlna_inotify: "yes" diff --git a/roles/minidlna/handlers/main.yml b/roles/minidlna/handlers/main.yml new file mode 100644 index 0000000..9864b98 --- /dev/null +++ b/roles/minidlna/handlers/main.yml @@ -0,0 +1,6 @@ +--- +# handlers file for minidlna +- name: restart minidlna + service: + name: minidlna + state: restart diff --git a/roles/minidlna/tasks/debian.yml b/roles/minidlna/tasks/debian.yml new file mode 100644 index 0000000..10bc4a1 --- /dev/null +++ b/roles/minidlna/tasks/debian.yml @@ -0,0 +1,6 @@ +--- +- name: Debian - Install minidlna + apt: + name: + - minidlna + state: present diff --git a/roles/minidlna/tasks/main.yml b/roles/minidlna/tasks/main.yml new file mode 100644 index 0000000..2c82863 --- /dev/null +++ b/roles/minidlna/tasks/main.yml @@ -0,0 +1,20 @@ +--- +# tasks file for nut +- name: Install os-specific packages + include_tasks: "{{ ansible_os_family | lower }}.yml" + +- name: Copy minidlna.conf + template: + src: minidlna.j2.conf + dest: /etc/minidlna.conf + owner: root + group: root + mode: 0644 + notify: restart minidlna + +- name: start and enable minidlna + service: + name: minidlna + enabled: yes + state: started + diff --git a/roles/minidlna/templates/minidlna.j2.conf b/roles/minidlna/templates/minidlna.j2.conf new file mode 100644 index 0000000..0054cfe --- /dev/null +++ b/roles/minidlna/templates/minidlna.j2.conf @@ -0,0 +1,132 @@ +# This is the configuration file for the MiniDLNA daemon, a DLNA/UPnP-AV media +# server. +# +# Unless otherwise noted, the commented out options show their default value. +# +# On Debian, you can also refer to the minidlna.conf(5) man page for +# documentation about this file. + +# Specify the user name or uid to run as (root by default). +# On Debian system command line option (from /etc/default/minidlna) overrides this. +#user=minidlna + + +# Path to the directory you want scanned for media files. +# +# This option can be specified more than once if you want multiple directories +# scanned. +# +# If you want to restrict a media_dir to a specific content type, you can +# prepend the directory name with a letter representing the type (A, P or V), +# followed by a comma, as so: +# * "A" for audio (eg. media_dir=A,/var/lib/minidlna/music) +# * "P" for pictures (eg. media_dir=P,/var/lib/minidlna/pictures) +# * "V" for video (eg. media_dir=V,/var/lib/minidlna/videos) +# * "PV" for pictures and video (eg. media_dir=PV,/var/lib/minidlna/digital_camera) +media_dir={{ minidlna_media_dir }} + +# Set this to merge all media_dir base contents into the root container +# (The default is no.) +#merge_media_dirs=no + +# Path to the directory that should hold the database and album art cache. +db_dir={{ minidlna_db_dir }} + +# Path to the directory that should hold the log file. +log_dir={{ minidlna_log_dir }} + +# Type and minimum level of importance of messages to be logged. +# +# The types are "artwork", "database", "general", "http", "inotify", +# "metadata", "scanner", "ssdp" and "tivo". +# +# The levels are "off", "fatal", "error", "warn", "info" or "debug". +# "off" turns of logging entirely, "fatal" is the highest level of importance +# and "debug" the lowest. +# +# The types are comma-separated, followed by an equal sign ("="), followed by a +# level that applies to the preceding types. This can be repeated, separating +# each of these constructs with a comma. +# +# The default is to log all types of messages at the "warn" level. +#log_level=general,artwork,database,inotify,scanner,metadata,http,ssdp,tivo=warn + +# Use a different container as the root of the directory tree presented to +# clients. The possible values are: +# * "." - standard container +# * "B" - "Browse Directory" +# * "M" - "Music" +# * "P" - "Pictures" +# * "V" - "Video" +# * Or, you can specify the ObjectID of your desired root container +# (eg. 1$F for Music/Playlists) +# If you specify "B" and the client device is audio-only then "Music/Folders" +# will be used as root. +root_container={{ minidlna_root_container }} + +# Network interface(s) to bind to (e.g. eth0), comma delimited. +# This option can be specified more than once. +network_interface={{ minidlna_network_interface }} + +# Port number for HTTP traffic (descriptions, SOAP, media transfer). +# This option is mandatory (or it must be specified on the command-line using +# "-p"). +port={{ minidlna_network_port }} + +# URL presented to clients (e.g. http://example.com:80). +#presentation_url=/ + +# Name that the DLNA server presents to clients. +# Defaults to "hostname: username". +friendly_name={{ minidlna_friendly_name }} + +# Serial number the server reports to clients. +# Defaults to the MAC address of nework interface. +#serial= + +# Model name the server reports to clients. +#model_name=Windows Media Connect compatible (MiniDLNA) + +# Model number the server reports to clients. +# Defaults to the version number of minidlna. +#model_number= + +# Automatic discovery of new files in the media_dir directory. +inotify={{ minidlna_inotify }} + +# List of file names to look for when searching for album art. +# Names should be delimited with a forward slash ("/"). +# This option can be specified more than once. +album_art_names=Cover.jpg/cover.jpg/AlbumArtSmall.jpg/albumartsmall.jpg +album_art_names=AlbumArt.jpg/albumart.jpg/Album.jpg/album.jpg +album_art_names=Folder.jpg/folder.jpg/Thumb.jpg/thumb.jpg + +# Strictly adhere to DLNA standards. +# This allows server-side downscaling of very large JPEG images, which may +# decrease JPEG serving performance on (at least) Sony DLNA products. +#strict_dlna=no + +# Support for streaming .jpg and .mp3 files to a TiVo supporting HMO. +#enable_tivo=no + +# Which method to use for registering in TiVo: 'bonjour' (default) or +# legacy 'beacon' +#tivo_discovery=bonjour + +# SSDP notify interval, in seconds. +#notify_interval=895 + +# Path to the MiniSSDPd socket, for MiniSSDPd support. +#minissdpdsocket=/run/minissdpd.sock + +# Always set SortCriteria to this value, regardless of the SortCriteria +# passed by the client +# e.g. force_sort_criteria=+upnp:class,+upnp:originalTrackNumber,+dc:title +#force_sort_criteria= + +# maximum number of simultaneous connections +# note: many clients open several simultaneous connections while streaming +#max_connections=50 + +# set this to yes to allow symlinks that point outside user-defined media_dirs. +#wide_links=no diff --git a/vars/home.yml b/vars/home.yml index 8fe0b21..1711602 100644 --- a/vars/home.yml +++ b/vars/home.yml @@ -1,11 +1,6 @@ --- -collectd_network_server: 192.168.2.240 -collectd_network_port: 25826 - ssh_publickey: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB7aeBuq7TC8bRATkXa3QY4icPSz9apd2ZSVfnMZD+ta waha@Combava-2022-03-23" - #ansible_become_pass: "{{ lookup('passwordstore', 'home/nas/admin')}}" - nfs_exports: - src: '/mnt/DocNas/Benjamin' @@ -32,3 +27,7 @@ samba_exports: public: 'yes' writable: 'yes' path: "/mnt/DocNas/Margot" + +collectd_network_server: 192.168.2.240 +collectd_network_port: 25826 + diff --git a/vars/nas.yml b/vars/nas.yml index 4df5c46..5d3614b 100644 --- a/vars/nas.yml +++ b/vars/nas.yml @@ -17,3 +17,7 @@ upss: - name: eaton650 driver: usbhid-ups port: auto + +# minidlna +minidlna_friendly_name: "Nas dlna" +minidlna_media_dir: /mnt/DocNas/Commun/musique/