Add mpd setup

This commit is contained in:
Sonny Bakker 2020-12-03 16:58:32 +01:00
parent 26562383cb
commit 5911d7ace4
11 changed files with 185 additions and 2 deletions

View file

@ -1,4 +1,5 @@
xdg_config_dir: "{{ ansible_env.HOME }}/.config" xdg_config_dir: "{{ ansible_env.HOME }}/.config"
xdg_script_dir: "{{ ansible_env.HOME }}/.local/bin"
packages: packages:
- firefox - firefox

View file

@ -0,0 +1,11 @@
mpd_listen_address: "127.0.0.1"
mpd_listen_port: "6600"
mpd_database_address: "10.8.0.1"
mpd_database_port: "21000"
mpd_configuration_dir: "{{ ansible_env.HOME }}/.config/mpd"
mpd_music_dir: "{{ ansible_env.HOME }}/music"
mpd_playlist_dir: "{{ mpd_configuration_dir }}/playlists"
mpd_state_path: "{{ mpd_configuration_dir }}/state"
mpd_sticker_path: "{{ mpd_configuration_dir }}/sticker.sql"

View file

@ -50,8 +50,7 @@
- include_tasks: gpg.yml # TODO - include_tasks: gpg.yml # TODO
- include_tasks: git.yml # TODO - include_tasks: git.yml # TODO
- include_tasks: mpv.yml - include_tasks: mpv.yml
- include_tasks: mpd.yml # TODO - include_tasks: mpd.yml
- include_tasks: nfs.yml # TODO
- include_tasks: postgres.yml # TODO - include_tasks: postgres.yml # TODO
- include_tasks: syncthing.yml # TODO depending on platform - include_tasks: syncthing.yml # TODO depending on platform
- include_tasks: openvpn.yml # TODO (laptop) - include_tasks: openvpn.yml # TODO (laptop)

View file

@ -0,0 +1,88 @@
- name: set up sudoers configuration
become: yes
template:
src: "sudoers.j2"
dest: "/etc/sudoers.d/10-sonny"
owner: root
group: root
mode: "0644"
- name: copy systemd configuration files
template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
loop:
- {
src: "mpd/service.j2",
dest: "{{ xdg_config_dir }}/systemd/user/mpd.service",
}
- {
src: "mpd/socket.j2",
dest: "{{ xdg_config_dir }}/systemd/user/mpd.socket",
}
- name: create mpd files
file:
path: "{{ item.path }}"
state: "{{ item.state }}"
loop:
- {
path: "{{ mpd_configuration_dir }}",
state: "directory",
}
- {
path: "{{ mpd_configuration_dir }}/playlists",
state: "directory",
}
- {
path: "{{ mpd_configuration_dir }}/log",
state: "touch",
}
- {
path: "{{ mpd_configuration_dir }}/database",
state: "touch",
}
- {
path: "{{ mpd_configuration_dir }}/sticker.sql",
state: "touch",
}
- {
path: "{{ mpd_configuration_dir }}/state",
state: "touch",
}
- name: copy configuration file
template:
src: "mpd/mpd.j2"
dest: "{{ mpd_configuration_dir }}/mpd.conf"
- name: copy nfs connection scripts
template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
mode: "0755"
loop:
- {
src: "mpd/music_mount.j2",
dest: "{{ xdg_script_dir }}/music_mount",
}
- {
src: "mpd/music_umount.j2",
dest: "{{ xdg_script_dir }}/music_umount",
}
- name: restart mpd service
systemd:
name: mpd.service
state: restarted
enabled: no
scope: user
when: platform == "desktop"
- name: enable mpd socket
systemd:
name: mpd.socket
state: started
enabled: yes
scope: user
when: platform == "desktop"

View file

@ -0,0 +1,44 @@
# {{ ansible_managed }} {{ ansible_date_time.time }} {{ ansible_date_time.date }}
music_directory "{{ mpd_music_dir }}"
playlist_directory "{{ mpd_playlist_dir }}"
state_file "{{ mpd_state_path }}"
sticker_file "{{ mpd_sticker_path }}"
log_level "secure"
bind_to_address "{{ mpd_listen_address }}"
port "{{ mpd_listen_port }}"
auto_update "yes"
filesystem_charset "UTF-8"
samplerate_converter "1"
database {
plugin "proxy"
host "{{ mpd_database_address }}"
port "{{ mpd_database_port }}"
}
audio_output {
type "pulse"
name "mpd"
replay_gain_handler "software"
mixer_type "hardware"
format "96000:24:1"
}
input {
enabled "no"
plugin "tidal"
}
input {
enabled "no"
plugin "qobuz"
}
decoder {
plugin "wildmidi"
enabled "no"
}

View file

@ -0,0 +1,5 @@
#!/bin/bash
#
# {{ ansible_managed }} {{ ansible_date_time.time }} {{ ansible_date_time.date }}
sudo mount -t nfs -o vers=4,soft,async,proto=tcp,port=2049 10.8.0.1:/srv/nfs4/music {{ mpd_music_dir }}

View file

@ -0,0 +1,6 @@
#!/bin/bash
#
# {{ ansible_managed }} {{ ansible_date_time.time }} {{ ansible_date_time.date }}
pkill cantata
sudo umount {{ mpd_music_dir }}

View file

@ -0,0 +1,14 @@
# {{ ansible_managed }} {{ ansible_date_time.time }} {{ ansible_date_time.date }}
[Unit]
Description=Music Player Daemon
Documentation=man:mpd(1) man:mpd.conf(5)
[Service]
Type=notify
ExecStartPre={{ xdg_script_dir }}/music_mount
ExecStart=/usr/bin/mpd --no-daemon {{ mpd_configuration_dir }}/mpd.conf
ExecStopPost={{ xdg_script_dir }}/music_umount
Restart=on-failure
RestartSec=15s
TimeoutStopSec=3

View file

@ -0,0 +1,11 @@
# {{ ansible_managed }} {{ ansible_date_time.time }} {{ ansible_date_time.date }}
[Socket]
ListenStream=/run/user/1000/mpd.socket
ListenStream={{ mpd_listen_port }}
Backlog=5
KeepAlive=true
PassCredentials=true
[Install]
WantedBy=sockets.target

View file

@ -0,0 +1,4 @@
# {{ ansible_managed }} {{ ansible_date_time.time }} {{ ansible_date_time.date }}
sonny ALL=(ALL) NOPASSWD: /usr/bin/mount
sonny ALL=(ALL) NOPASSWD: /usr/bin/umount