diff --git a/home.yml b/home.yml index 6092a2c..fe53259 100644 --- a/home.yml +++ b/home.yml @@ -36,10 +36,9 @@ tags: - docker - - role: pihole + - role: mpd tags: - - docker - - pihole + - mpd - role: minidlna tags: diff --git a/roles/mpd/.travis.yml b/roles/mpd/.travis.yml new file mode 100644 index 0000000..36bbf62 --- /dev/null +++ b/roles/mpd/.travis.yml @@ -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/ \ No newline at end of file diff --git a/roles/mpd/.yamllint b/roles/mpd/.yamllint new file mode 100644 index 0000000..8827676 --- /dev/null +++ b/roles/mpd/.yamllint @@ -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 diff --git a/roles/mpd/defaults/main.yml b/roles/mpd/defaults/main.yml new file mode 100644 index 0000000..d1b468a --- /dev/null +++ b/roles/mpd/defaults/main.yml @@ -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" + diff --git a/roles/mpd/handlers/main.yml b/roles/mpd/handlers/main.yml new file mode 100644 index 0000000..ad5aa8e --- /dev/null +++ b/roles/mpd/handlers/main.yml @@ -0,0 +1,6 @@ +--- +# handlers file for mpd +- name: restart mpd + service: + name: mpd + state: restarted diff --git a/roles/mpd/molecule/default/INSTALL.rst b/roles/mpd/molecule/default/INSTALL.rst new file mode 100644 index 0000000..0c4bf5c --- /dev/null +++ b/roles/mpd/molecule/default/INSTALL.rst @@ -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' diff --git a/roles/mpd/molecule/default/converge.yml b/roles/mpd/molecule/default/converge.yml new file mode 100644 index 0000000..31c1968 --- /dev/null +++ b/roles/mpd/molecule/default/converge.yml @@ -0,0 +1,7 @@ +--- +- name: Converge + hosts: all + tasks: + - name: "Include mpd" + include_role: + name: "mpd" diff --git a/roles/mpd/molecule/default/molecule.yml b/roles/mpd/molecule/default/molecule.yml new file mode 100644 index 0000000..69bc10b --- /dev/null +++ b/roles/mpd/molecule/default/molecule.yml @@ -0,0 +1,11 @@ +--- +dependency: + name: galaxy +driver: + name: vagrant +platforms: + - name: instance +provisioner: + name: ansible +verifier: + name: ansible diff --git a/roles/mpd/molecule/default/verify.yml b/roles/mpd/molecule/default/verify.yml new file mode 100644 index 0000000..79044cd --- /dev/null +++ b/roles/mpd/molecule/default/verify.yml @@ -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 diff --git a/roles/mpd/tasks/debian.yml b/roles/mpd/tasks/debian.yml new file mode 100644 index 0000000..c00d64f --- /dev/null +++ b/roles/mpd/tasks/debian.yml @@ -0,0 +1,7 @@ +--- +- name: Debian - Install mpd + apt: + name: + - mpd + - mpc + state: present diff --git a/roles/mpd/tasks/main.yml b/roles/mpd/tasks/main.yml new file mode 100644 index 0000000..463b757 --- /dev/null +++ b/roles/mpd/tasks/main.yml @@ -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 diff --git a/roles/mpd/templates/mpd.conf.j2 b/roles/mpd/templates/mpd.conf.j2 new file mode 100644 index 0000000..ed458a1 --- /dev/null +++ b/roles/mpd/templates/mpd.conf.j2 @@ -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 %} diff --git a/roles/mpd/vars/main.yml b/roles/mpd/vars/main.yml new file mode 100644 index 0000000..8bc0403 --- /dev/null +++ b/roles/mpd/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for mpd diff --git a/vars/nas.yml b/vars/nas.yml index 5d3614b..85c143c 100644 --- a/vars/nas.yml +++ b/vars/nas.yml @@ -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"