Feat: add mpd role and enable it to nas

This commit is contained in:
Bertrand Benjamin 2022-08-18 21:42:48 +02:00
parent db8a7e758e
commit 5ad74e8f9d
14 changed files with 208 additions and 3 deletions

View File

@ -36,10 +36,9 @@
tags:
- docker
- role: pihole
- role: mpd
tags:
- docker
- pihole
- mpd
- role: minidlna
tags:

29
roles/mpd/.travis.yml Normal file
View File

@ -0,0 +1,29 @@
---
language: python
python: "2.7"
# Use the new container infrastructure
sudo: false
# Install ansible
addons:
apt:
packages:
- python-pip
install:
# Install ansible
- pip install ansible
# Check ansible version
- ansible --version
# Create ansible.cfg with correct roles_path
- printf '[defaults]\nroles_path=../' >ansible.cfg
script:
# Basic role syntax check
- ansible-playbook tests/test.yml -i tests/inventory --syntax-check
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/

33
roles/mpd/.yamllint Normal file
View File

@ -0,0 +1,33 @@
---
# Based on ansible-lint config
extends: default
rules:
braces:
max-spaces-inside: 1
level: error
brackets:
max-spaces-inside: 1
level: error
colons:
max-spaces-after: -1
level: error
commas:
max-spaces-after: -1
level: error
comments: disable
comments-indentation: disable
document-start: disable
empty-lines:
max: 3
level: error
hyphens:
level: error
indentation: disable
key-duplicates: enable
line-length: disable
new-line-at-end-of-file: disable
new-lines:
type: unix
trailing-spaces: disable
truthy: disable

View File

@ -0,0 +1,22 @@
---
# defaults file for mpd
mpd_name: Music Player Daemon
mpd_restore_paused: true
mpd_auto_update: true
mpd_follow_inside_symlinks: true
mpd_follow_outside_symlinks: false
mpd_music_directory: /var/lib/mpd/music
mpd_playlist_directory: /var/lib/mpd/playlists
mpd_db_file: /var/lib/mpd/mpd.db
mpd_sticker_file: /var/lib/mpd/sticker.db
mpd_state_file: /var/lib/mpd/mpdstate
mpd_user: mpd
mpd_bind_to_address: any
mpd_outputs:
- name: "Null Output"
type: "null"

View File

@ -0,0 +1,6 @@
---
# handlers file for mpd
- name: restart mpd
service:
name: mpd
state: restarted

View File

@ -0,0 +1,23 @@
*********************************
Vagrant driver installation guide
*********************************
Requirements
============
* Vagrant
* Virtualbox, Parallels, VMware Fusion, VMware Workstation or VMware Desktop
Install
=======
Please refer to the `Virtual environment`_ documentation for installation best
practices. If not using a virtual environment, please consider passing the
widely recommended `'--user' flag`_ when invoking ``pip``.
.. _Virtual environment: https://virtualenv.pypa.io/en/latest/
.. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site
.. code-block:: bash
$ pip install 'molecule_vagrant'

View File

@ -0,0 +1,7 @@
---
- name: Converge
hosts: all
tasks:
- name: "Include mpd"
include_role:
name: "mpd"

View File

@ -0,0 +1,11 @@
---
dependency:
name: galaxy
driver:
name: vagrant
platforms:
- name: instance
provisioner:
name: ansible
verifier:
name: ansible

View File

@ -0,0 +1,10 @@
---
# This is an example playbook to execute Ansible tests.
- name: Verify
hosts: all
gather_facts: false
tasks:
- name: Example assertion
assert:
that: true

View File

@ -0,0 +1,7 @@
---
- name: Debian - Install mpd
apt:
name:
- mpd
- mpc
state: present

13
roles/mpd/tasks/main.yml Normal file
View File

@ -0,0 +1,13 @@
---
# tasks file for mpd
- name: Install os-specific packages
include_tasks: "{{ ansible_os_family | lower }}.yml"
- name: Copy mpd.conf
template:
src: mpd.conf.j2
dest: /etc/mpd.conf
owner: root
group: root
mode: 0644
notify: restart mpd

View File

@ -0,0 +1,32 @@
music_directory "{{ mpd_music_directory }}"
playlist_directory "{{ mpd_playlist_directory }}"
db_file "{{ mpd_db_file }}"
sticker_file "{{ mpd_sticker_file }}"
state_file "{{ mpd_state_file }}"
user "{{ mpd_user }}"
bind_to_address "{{ mpd_bind_to_address }}"
log_file "syslog"
restore_paused "{% if mpd_restore_paused %}yes{% else %}no{% endif %}"
auto_update "{% if mpd_auto_update %}yes{% else %}no{% endif %}"
follow_inside_symlinks "{% if mpd_follow_inside_symlinks %}yes{% else %}no{% endif %}"
follow_outside_symlinks "{% if mpd_follow_outside_symlinks %}yes{% else %}no{% endif %}"
zeroconf_enabled "yes"
zeroconf_name "{{ mpd_name }}"
input {
plugin "curl"
verify_peer "yes"
verify_host "yes"
}
{% for output in mpd_outputs %}
audio_output {
{% for k, v in output.items() %}
{{ k }} "{{ v }}"
{% endfor %}
}
{% endfor %}

2
roles/mpd/vars/main.yml Normal file
View File

@ -0,0 +1,2 @@
---
# vars file for mpd

View File

@ -21,3 +21,14 @@ upss:
# minidlna
minidlna_friendly_name: "Nas dlna"
minidlna_media_dir: /mnt/DocNas/Commun/musique/
# Mpd
mpd_name: Mpd NAS
mpd_music_directory: /mnt/DocNas/Commun/musique
mpd_outputs:
- type: "httpd"
name: "Nas mpd stream"
encoder: "vorbis" # optional, vorbis or lame
port: "8000"
bitrate: "128" # do not define if quality is defined
format: "44100:16:1"