Add MPD docker setup
This commit is contained in:
parent
bd503eaa0d
commit
4259710626
10 changed files with 170 additions and 77 deletions
|
|
@ -38,13 +38,6 @@
|
|||
state: restarted
|
||||
enabled: true
|
||||
|
||||
- name: restart mpd service
|
||||
become: true
|
||||
systemd:
|
||||
name: mpd
|
||||
state: restarted
|
||||
enabled: true
|
||||
|
||||
- name: restart certbot
|
||||
become: true
|
||||
systemd:
|
||||
|
|
|
|||
141
tasks/mpd.yml
141
tasks/mpd.yml
|
|
@ -1,71 +1,106 @@
|
|||
# TODO: use docker setup
|
||||
- name: create mpd directories
|
||||
- name: Stop systemd mpd service
|
||||
become: true
|
||||
file:
|
||||
ansible.builtin.systemd:
|
||||
name: mpd
|
||||
state: stopped
|
||||
enabled: false
|
||||
|
||||
- name: Stop systemd mpd socket
|
||||
become: true
|
||||
ansible.builtin.systemd:
|
||||
name: mpd.socket
|
||||
state: stopped
|
||||
enabled: false
|
||||
|
||||
- name: Remove previous configurations
|
||||
become: true
|
||||
ansible.builtin.file:
|
||||
path: '{{ item.path }}'
|
||||
state: absent
|
||||
loop:
|
||||
- path: '/etc/systemd/system/mpd.service.d'
|
||||
- path: '/etc/systemd/system/mpd.socket.d'
|
||||
|
||||
- name: Create mpd directories
|
||||
become: true
|
||||
ansible.builtin.file:
|
||||
path: '{{ item.path }}'
|
||||
mode: '{{ item.mode }}'
|
||||
owner: '{{ item.owner }}'
|
||||
group: '{{ item.group }}'
|
||||
mode: '0755'
|
||||
state: directory
|
||||
loop:
|
||||
- {
|
||||
path: '{{ ansible_env.HOME }}/.config/mpd',
|
||||
mode: 755,
|
||||
owner: 'sonny',
|
||||
group: 'sonny',
|
||||
}
|
||||
- {
|
||||
path: '/etc/systemd/system/mpd.service.d',
|
||||
mode: 755,
|
||||
owner: 'root',
|
||||
group: 'root',
|
||||
}
|
||||
- {
|
||||
path: '/etc/systemd/system/mpd.socket.d',
|
||||
mode: 755,
|
||||
owner: 'root',
|
||||
group: 'root',
|
||||
}
|
||||
notify: restart mpd service
|
||||
- path: '{{ mpd_config_dir }}'
|
||||
owner: sonny
|
||||
group: sonny
|
||||
|
||||
- name: copy mpd templates
|
||||
- path: '{{ mpd_playlist_dir }}'
|
||||
owner: sonny
|
||||
group: sonny
|
||||
|
||||
- path: '{{ mpd_state_dir }}'
|
||||
owner: sonny
|
||||
group: sonny
|
||||
|
||||
- path: '{{ mpd_app_dir }}'
|
||||
owner: root
|
||||
group: root
|
||||
|
||||
- name: Copy mpd templates
|
||||
become: true
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: '{{ item.src }}'
|
||||
dest: '{{ item.dest }}'
|
||||
mode: '{{ item.mode }}'
|
||||
owner: '{{ item.owner }}'
|
||||
group: '{{ item.group }}'
|
||||
loop:
|
||||
- {
|
||||
src: 'templates/systemd/mpd/service.j2',
|
||||
dest: '/etc/systemd/system/mpd.service.d/override.conf',
|
||||
mode: 755,
|
||||
owner: 'root',
|
||||
group: 'root',
|
||||
}
|
||||
- {
|
||||
src: 'templates/systemd/mpd/socket.j2',
|
||||
dest: '/etc/systemd/system/mpd.socket.d/override.conf',
|
||||
mode: 755,
|
||||
owner: 'root',
|
||||
group: 'root',
|
||||
}
|
||||
- {
|
||||
src: 'templates/mpd.j2',
|
||||
dest: '{{ ansible_env.HOME }}/.config/mpd/mpd.conf',
|
||||
mode: 0640,
|
||||
owner: 'sonny',
|
||||
group: 'sonny',
|
||||
}
|
||||
notify: restart mpd service
|
||||
- src: templates/mpd/config.j2
|
||||
dest: '{{ mpd_config_dir }}/mpd.conf'
|
||||
mode: '0640'
|
||||
owner: sonny
|
||||
group: sonny
|
||||
|
||||
- name: created mpd files
|
||||
file:
|
||||
- src: templates/mpd/dockerfile.j2
|
||||
dest: '{{ mpd_app_dir }}/Dockerfile'
|
||||
mode: '0755'
|
||||
owner: sonny
|
||||
group: sonny
|
||||
|
||||
- src: templates/mpd/docker-compose.j2
|
||||
dest: '{{ mpd_app_dir }}/docker-compose.yml'
|
||||
mode: '0755'
|
||||
owner: sonny
|
||||
group: sonny
|
||||
|
||||
- name: Create mpd files
|
||||
ansible.builtin.file:
|
||||
path: '{{ item }}'
|
||||
mode: '0755'
|
||||
state: touch
|
||||
loop:
|
||||
- '{{ ansible_env.HOME }}/.config/mpd/db'
|
||||
- '{{ ansible_env.HOME }}/.config/mpd/state'
|
||||
- '{{ ansible_env.HOME }}/.config/mpd/sticker.sql'
|
||||
notify: restart mpd service
|
||||
- '{{ mpd_config_dir }}/db'
|
||||
- '{{ mpd_config_dir }}/sticker.sql'
|
||||
- '{{ mpd_state_dir }}/state'
|
||||
|
||||
- name: Stop current containers
|
||||
community.docker.docker_compose_v2:
|
||||
project_src: '{{ mpd_app_dir }}'
|
||||
state: stopped
|
||||
|
||||
- name: Build image
|
||||
community.docker.docker_compose_v2:
|
||||
project_src: '{{ mpd_app_dir }}'
|
||||
build: policy
|
||||
state: stopped
|
||||
|
||||
- name: Remove dangling containers
|
||||
community.docker.docker_compose_v2:
|
||||
project_src: '{{ mpd_app_dir }}'
|
||||
remove_orphans: true
|
||||
state: stopped
|
||||
|
||||
- name: Start container
|
||||
community.docker.docker_compose_v2:
|
||||
project_src: '{{ mpd_app_dir }}'
|
||||
state: present
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
# {{ ansible_managed }}
|
||||
#
|
||||
# An example configuration file for MPD.
|
||||
# Read the user manual for documentation: http://www.musicpd.org/doc/user/
|
||||
# or /usr/share/doc/mpd/user-manual.html
|
||||
|
|
@ -13,7 +11,15 @@
|
|||
# be disabled and audio files will only be accepted over ipc socket (using
|
||||
# file:// protocol) or streaming files over an accepted protocol.
|
||||
#
|
||||
music_directory "{{ mpd_music_dir }}"
|
||||
music_directory "/app/music"
|
||||
|
||||
#
|
||||
# This setting sets the MPD internal playlist directory. The purpose of this
|
||||
# directory is storage for playlists created by MPD. The server will use
|
||||
# playlist files not created by the server but only if they are in the MPD
|
||||
# format. This setting defaults to playlist saving being disabled.
|
||||
#
|
||||
playlist_directory "/app/playlists"
|
||||
|
||||
#
|
||||
# This setting sets the location of the MPD database. This file is used to
|
||||
|
|
@ -22,8 +28,7 @@ music_directory "{{ mpd_music_dir }}"
|
|||
# MPD to accept files over ipc socket (using file:// protocol) or streaming
|
||||
# files over an accepted protocol.
|
||||
#
|
||||
# TODO: use variable for this, usable for task and this configuration
|
||||
db_file "/home/sonny/.config/mpd/db"
|
||||
db_file "/app/config/db"
|
||||
|
||||
#
|
||||
# These settings are the locations for the daemon log files for the daemon.
|
||||
|
|
@ -33,14 +38,12 @@ db_file "/home/sonny/.config/mpd/db"
|
|||
log_level "secure"
|
||||
|
||||
#
|
||||
# TODO: use variable for this, usable for task and this configuration
|
||||
state_file "/home/sonny/.config/mpd/state"
|
||||
state_file "/app/state/state"
|
||||
#
|
||||
# The location of the sticker database. This is a database which
|
||||
# manages dynamic information attached to songs.
|
||||
#
|
||||
# TODO: use variable for this, usable for task and this configuration
|
||||
sticker_file "/home/sonny/.config/mpd/sticker.sql"
|
||||
sticker_file "/app/config/sticker.sql"
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
|
|
@ -52,7 +55,7 @@ sticker_file "/home/sonny/.config/mpd/sticker.sql"
|
|||
# initialization. This setting is disabled by default and MPD is run as the
|
||||
# current user.
|
||||
#
|
||||
user "sonny"
|
||||
# user "mpd"
|
||||
|
||||
#
|
||||
# This setting sets the address for the daemon to listen on. Careful attention
|
||||
|
|
@ -62,7 +65,7 @@ user "sonny"
|
|||
# activation is in use.
|
||||
#
|
||||
# For network
|
||||
bind_to_address "{{ vpn_listen_address }}"
|
||||
bind_to_address "0.0.0.0"
|
||||
|
||||
#
|
||||
# This setting is the TCP port that is desired for the daemon to get assigned
|
||||
|
|
@ -97,7 +100,7 @@ audio_output {
|
|||
name "HTTP high quality stream"
|
||||
encoder "opus"
|
||||
port "{{ mpd_http_stream_port }}"
|
||||
bind_to_address "{{ vpn_listen_address }}"
|
||||
bind_to_address "0.0.0.0"
|
||||
bitrate "128000"
|
||||
format "192000:24:2"
|
||||
always_on "yes"
|
||||
|
|
@ -110,7 +113,7 @@ audio_output {
|
|||
name "HTTP mobile stream"
|
||||
encoder "opus"
|
||||
port "{{ mpd_http_mobile_stream_port }}"
|
||||
bind_to_address "{{ vpn_listen_address }}"
|
||||
bind_to_address "0.0.0.0"
|
||||
bitrate "96000"
|
||||
format "44100:16:2"
|
||||
always_on "yes"
|
||||
|
|
@ -118,7 +121,6 @@ audio_output {
|
|||
max_clients "1"
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Character Encoding ##########################################################
|
||||
#
|
||||
22
templates/mpd/docker-compose.j2
Normal file
22
templates/mpd/docker-compose.j2
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
# {{ ansible_managed }}
|
||||
|
||||
networks:
|
||||
mpd-net:
|
||||
ipam:
|
||||
config:
|
||||
- subnet: '{{ mpd_subnet }}'
|
||||
|
||||
services:
|
||||
mpd:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
volumes:
|
||||
- {{ mpd_config_dir }}:/app/config
|
||||
- {{ mpd_state_dir }}:/app/state
|
||||
- {{ mpd_playlist_dir }}:/app/playlists
|
||||
- {{ mpd_music_dir }}:/app/music
|
||||
restart: always
|
||||
networks:
|
||||
mpd-net:
|
||||
ipv4_address: '{{ mpd_app_ip }}'
|
||||
25
templates/mpd/dockerfile.j2
Normal file
25
templates/mpd/dockerfile.j2
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
# {{ ansible_managed }}
|
||||
|
||||
FROM alpine:latest
|
||||
|
||||
RUN apk --no-cache add \
|
||||
mpd; \
|
||||
|
||||
RUN useradd \
|
||||
--uid 1000 \
|
||||
--guid 1000 \
|
||||
--groups mpd \
|
||||
--shell /sbin/nologin \
|
||||
--no-create-home \
|
||||
--no-user-group \
|
||||
sonny
|
||||
|
||||
USER sonny
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN mkdir /app/config /app/state /app/playlists
|
||||
|
||||
EXPOSE {{ mpd_port }}/tcp {{ mpd_http_stream_port }}/tcp {{ mpd_http_mobile_stream_port }}/tcp
|
||||
|
||||
CMD ["/usr/bin/mpd", "--no-daemon", "--stdout", "/app/config/mpd.conf"]
|
||||
|
|
@ -9,3 +9,4 @@
|
|||
{{ syncthing_nginx_ip }} {{ syncthing_domain }}
|
||||
{{ radicale_nginx_ip }} {{ radicale_domain }}
|
||||
{{ jellyfin_nginx_ip }} {{ jellyfin_domain }}
|
||||
{{ mpd_app_ip }} {{ mpd_domain }}
|
||||
|
|
|
|||
|
|
@ -61,9 +61,9 @@ table ip filter {
|
|||
|
||||
tcp dport 80 ip saddr {{ vpn_subnet }} ip daddr {{ radicale_nginx_ip }} accept comment "Radicale"
|
||||
|
||||
tcp dport {{ mpd_port }} ip saddr . ip daddr @vpn_set accept comment "MPD"
|
||||
tcp dport {{ mpd_http_stream_port }} ip saddr . ip daddr @vpn_set accept comment "MPD HTTP stream"
|
||||
tcp dport {{ mpd_http_mobile_stream_port }} ip saddr . ip daddr @vpn_set accept comment "MPD HTTP mobile stream"
|
||||
tcp dport {{ mpd_port }} ip saddr {{ vpn_subnet }} ip daddr {{ mpd_app_ip }} accept comment "MPD"
|
||||
tcp dport {{ mpd_http_stream_port }} ip saddr {{ vpn_subnet }} ip daddr {{ mpd_app_ip }} accept comment "MPD HTTP stream"
|
||||
tcp dport {{ mpd_http_mobile_stream_port }} ip saddr {{ vpn_subnet }} ip daddr {{ mpd_app_ip }} accept comment "MPD HTTP mobile stream"
|
||||
}
|
||||
|
||||
set vpn_media_set {
|
||||
|
|
@ -83,6 +83,7 @@ table ip filter {
|
|||
iifname {{ vpn_interface }} ip saddr {{ vpn_subnet }} ip daddr {{ transmission_nginx_ip }} accept
|
||||
iifname {{ vpn_interface }} ip saddr {{ vpn_subnet }} ip daddr {{ syncthing_nginx_ip }} accept
|
||||
iifname {{ vpn_interface }} ip saddr {{ vpn_subnet }} ip daddr {{ radicale_nginx_ip }} accept
|
||||
iifname {{ vpn_interface }} ip saddr {{ vpn_subnet }} ip daddr {{ mpd_app_ip }} accept
|
||||
|
||||
iifname {{ vpn_media_interface }} ip saddr {{ vpn_media_subnet }} ip daddr {{ jellyfin_nginx_ip }} accept
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,3 +15,7 @@ packages:
|
|||
vpn_config_dir: '/etc/wireguard'
|
||||
|
||||
hostname: 'fudiggity'
|
||||
|
||||
xdg_config_dir: '/home/sonny/.config'
|
||||
xdg_data_dir: '/home/sonny/.local/share'
|
||||
xdg_state_dir: '/home/sonny/.local/state'
|
||||
|
|
|
|||
|
|
@ -1 +1,6 @@
|
|||
mpd_app_dir: '/srv/docker/mpd'
|
||||
mpd_music_dir: '/home/sonny/music'
|
||||
|
||||
mpd_config_dir: '{{ xdg_config_dir }}/mpd'
|
||||
mpd_playlist_dir: '{{ xdg_data_dir }}/mpd/playlists'
|
||||
mpd_state_dir: '{{ xdg_state_dir }}/mpd'
|
||||
|
|
|
|||
|
|
@ -25,9 +25,14 @@ vpn_media_port: 51903
|
|||
vpn_media_interface: 'wg1'
|
||||
vpn_media_domain: 'media-vpn.{{ domain_name }}'
|
||||
|
||||
mpd_domain: 'mpd.{{ domain_name }}'
|
||||
mpd_listen_address: '0.0.0.0'
|
||||
mpd_prefix: 24
|
||||
mpd_subnet: '172.128.238.0/{{ mpd_prefix }}'
|
||||
mpd_port: 21000
|
||||
mpd_http_stream_port: 8000
|
||||
mpd_http_mobile_stream_port: 8001
|
||||
mpd_app_ip: '172.128.238.10'
|
||||
|
||||
forgejo_ip: '127.0.0.1'
|
||||
forgejo_port: 3000
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue