Compare commits
3 commits
1d8e07bf04
...
7cd44bbe53
Author | SHA1 | Date | |
---|---|---|---|
7cd44bbe53 | |||
43075d27fe | |||
301529271d |
13 changed files with 191 additions and 101 deletions
|
@ -11,6 +11,10 @@ root_access:
|
||||||
- polyfloyd
|
- polyfloyd
|
||||||
|
|
||||||
nginx_client_max_body_size: 512M
|
nginx_client_max_body_size: 512M
|
||||||
|
nginx_sites:
|
||||||
|
- server_name: "music.bitlair.nl"
|
||||||
|
snippets:
|
||||||
|
- "music-nginx.j2"
|
||||||
|
|
||||||
music_domain: music.bitlair.nl
|
music_domain: music.bitlair.nl
|
||||||
acme_san_domains:
|
acme_san_domains:
|
||||||
|
|
|
@ -6,5 +6,5 @@
|
||||||
- { role: "acme", tags: [ "acme" ] }
|
- { role: "acme", tags: [ "acme" ] }
|
||||||
- { role: "deb_forgejo", tags: [ "deb_forgejo" ] }
|
- { role: "deb_forgejo", tags: [ "deb_forgejo" ] }
|
||||||
- { role: "go", tags: [ "go" ] }
|
- { role: "go", tags: [ "go" ] }
|
||||||
# - { role: "nginx", tags: [ "nginx" ] }
|
- { role: "nginx", tags: [ "nginx" ] }
|
||||||
- { role: "music", tags: [ "music" ] }
|
- { role: "music", tags: [ "music" ] }
|
||||||
|
|
|
@ -1,2 +1,5 @@
|
||||||
music_audio_user: audio
|
music_audio_user: audio
|
||||||
|
music_audio_group: audio
|
||||||
|
music_librespot_user: librespot
|
||||||
|
|
||||||
music_mqtt_mpd_volume: bitlair/music/space/volume
|
music_mqtt_mpd_volume: bitlair/music/space/volume
|
||||||
|
|
|
@ -2,19 +2,25 @@
|
||||||
- ansible.builtin.import_tasks:
|
- ansible.builtin.import_tasks:
|
||||||
file: ../../common/handlers/main.yaml
|
file: ../../common/handlers/main.yaml
|
||||||
|
|
||||||
|
- name: restart mpd
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
name: mpd
|
||||||
|
state: restarted
|
||||||
|
daemon_reload: true
|
||||||
|
|
||||||
- name: Restart trollibox
|
- name: Restart trollibox
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
name: trollibox
|
name: trollibox
|
||||||
state: restarted
|
state: restarted
|
||||||
daemon_reload: true
|
daemon_reload: true
|
||||||
|
|
||||||
- name: Rebuild librespot
|
- name: rebuild librespot
|
||||||
ansible.builtin.command:
|
ansible.builtin.command:
|
||||||
cmd: /root/.cargo/bin/cargo build --release --features jackaudio-backend
|
cmd: /root/.cargo/bin/cargo build --release --features pulseaudio-backend
|
||||||
args:
|
args:
|
||||||
chdir: /opt/librespot
|
chdir: /opt/librespot
|
||||||
|
|
||||||
- name: Restart librespot
|
- name: restart librespot
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
name: librespot
|
name: librespot
|
||||||
state: restarted
|
state: restarted
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
---
|
---
|
||||||
- name: Install dependencies
|
- name: Create librespot user
|
||||||
ansible.builtin.apt:
|
user:
|
||||||
name: libjack-jackd2-dev
|
name: "{{ music_librespot_user }}"
|
||||||
state: present
|
system: true
|
||||||
|
home: /var/lib/librespot
|
||||||
|
groups:
|
||||||
|
- "{{ music_audio_group }}"
|
||||||
|
|
||||||
- name: Clone librespot source
|
- name: Clone librespot source
|
||||||
ansible.builtin.git:
|
ansible.builtin.git:
|
||||||
|
@ -11,8 +14,8 @@
|
||||||
dest: /opt/librespot
|
dest: /opt/librespot
|
||||||
accept_hostkey: yes
|
accept_hostkey: yes
|
||||||
notify:
|
notify:
|
||||||
- Rebuild librespot
|
- rebuild librespot
|
||||||
- Restart librespot
|
- restart librespot
|
||||||
|
|
||||||
- name: Install service file
|
- name: Install service file
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
|
@ -21,7 +24,7 @@
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: 0644
|
mode: 0644
|
||||||
notify: Restart librespot
|
notify: restart librespot
|
||||||
|
|
||||||
- name: Enable Librespot
|
- name: Enable Librespot
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
|
@ -29,3 +32,5 @@
|
||||||
state: started
|
state: started
|
||||||
enabled: true
|
enabled: true
|
||||||
daemon_reload: true
|
daemon_reload: true
|
||||||
|
|
||||||
|
- meta: flush_handlers
|
||||||
|
|
|
@ -23,12 +23,3 @@
|
||||||
file: soundboard.yaml
|
file: soundboard.yaml
|
||||||
tags:
|
tags:
|
||||||
- music_soundboard
|
- music_soundboard
|
||||||
|
|
||||||
- name: Install nginx config
|
|
||||||
ansible.builtin.template:
|
|
||||||
src: nginx-site.conf
|
|
||||||
dest: /etc/nginx/sites-enabled/trollibox
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
mode: 0644
|
|
||||||
notify: Reload nginx
|
|
||||||
|
|
|
@ -1,14 +1,32 @@
|
||||||
---
|
---
|
||||||
|
|
||||||
- name: Install MPD
|
- name: Install MPD
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
name:
|
name: mpd
|
||||||
- jackd
|
|
||||||
- mpd
|
|
||||||
- python3-mpd
|
|
||||||
- python3-serial
|
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
|
- name: Add mpd user to the {{ music_audio_group }} group
|
||||||
|
user:
|
||||||
|
name: mpd
|
||||||
|
groups:
|
||||||
|
- "{{ music_audio_group }}"
|
||||||
|
notify: restart mpd
|
||||||
|
|
||||||
|
- name: Install mpd file
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: "{{ item.src }}"
|
||||||
|
dest: "{{ item.dest }}"
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0644
|
||||||
|
notify: restart mpd
|
||||||
|
with_items:
|
||||||
|
- src: mpd.conf
|
||||||
|
dest: /etc/mpd.conf
|
||||||
|
- src: mpd.service
|
||||||
|
dest: /etc/systemd/system/mpd.service
|
||||||
|
- src: mpd_state
|
||||||
|
dest: /var/lib/mpd/state.default
|
||||||
|
|
||||||
- name: Install mpd-volume-to-mqtt script
|
- name: Install mpd-volume-to-mqtt script
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: mpd-volume-to-mqtt.sh
|
src: mpd-volume-to-mqtt.sh
|
||||||
|
@ -34,6 +52,13 @@
|
||||||
enabled: true
|
enabled: true
|
||||||
daemon_reload: true
|
daemon_reload: true
|
||||||
|
|
||||||
|
- name: Install skipbutton depedencies
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name:
|
||||||
|
- python3-mpd
|
||||||
|
- python3-serial
|
||||||
|
state: present
|
||||||
|
|
||||||
- name: Clone skipbutton source
|
- name: Clone skipbutton source
|
||||||
ansible.builtin.git:
|
ansible.builtin.git:
|
||||||
repo: https://github.com/bitlair/skipbutton.git
|
repo: https://github.com/bitlair/skipbutton.git
|
||||||
|
|
|
@ -3,16 +3,15 @@
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Spotify through Librespot
|
Description=Spotify through Librespot
|
||||||
After=network.target
|
After=network.target
|
||||||
Requires=jackd.service
|
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=2s
|
RestartSec=2s
|
||||||
ExecStart=/opt/librespot/target/release/librespot --name Trollibox --backend jackaudio
|
ExecStart=/opt/librespot/target/release/librespot --name Trollibox --backend pulseaudio --volume-ctrl linear
|
||||||
User={{ music_audio_user }}
|
Environment="PULSE_SERVER=/tmp/pipewire-pulse-socket"
|
||||||
Group={{ music_audio_user }}
|
Environment="XDG_RUNTIME_DIR=/run/user/0"
|
||||||
AmbientCapabilities=CAP_IPC_LOCK,CAP_SYS_NICE
|
User={{ music_librespot_user }}
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
|
40
roles/music/templates/mpd.conf
Normal file
40
roles/music/templates/mpd.conf
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
# {{ ansible_managed }}
|
||||||
|
|
||||||
|
user "mpd"
|
||||||
|
group "{{ music_audio_group }}"
|
||||||
|
|
||||||
|
bind_to_address "any"
|
||||||
|
port "6600"
|
||||||
|
max_connections "20"
|
||||||
|
|
||||||
|
zeroconf_enabled "yes"
|
||||||
|
zeroconf_name "MPD @ %h"
|
||||||
|
|
||||||
|
music_directory "/srv/media/music"
|
||||||
|
auto_update "yes"
|
||||||
|
filesystem_charset "UTF-8"
|
||||||
|
|
||||||
|
playlist_directory "/var/lib/mpd/playlists"
|
||||||
|
db_file "/var/lib/mpd/tag_cache"
|
||||||
|
state_file "/var/lib/mpd/state"
|
||||||
|
sticker_file "/var/lib/mpd/sticker.sql"
|
||||||
|
|
||||||
|
input {
|
||||||
|
plugin "curl" # Required for web streams.
|
||||||
|
}
|
||||||
|
|
||||||
|
decoder {
|
||||||
|
plugin "hybrid_dsd"
|
||||||
|
enabled "no"
|
||||||
|
}
|
||||||
|
|
||||||
|
decoder {
|
||||||
|
plugin "wildmidi"
|
||||||
|
enabled "no"
|
||||||
|
}
|
||||||
|
|
||||||
|
audio_output {
|
||||||
|
type "pulse"
|
||||||
|
name "Pulse"
|
||||||
|
server "/tmp/pipewire-pulse-socket"
|
||||||
|
}
|
21
roles/music/templates/mpd.service
Normal file
21
roles/music/templates/mpd.service
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# {{ ansible_managed }}
|
||||||
|
|
||||||
|
[Unit]
|
||||||
|
Description=Music Player Daemon
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
ExecStartPre=/bin/mkdir -p /run/mpd
|
||||||
|
ExecStartPre=/bin/chown -R mpd:nogroup /run/mpd
|
||||||
|
ExecStartPre=/bin/touch /var/log/mpd.log
|
||||||
|
ExecStartPre=/bin/chown mpd:nogroup /var/log/mpd.log
|
||||||
|
ExecStartPre=/usr/bin/cp /var/lib/mpd/state.default /var/lib/mpd/state
|
||||||
|
ExecStart=/usr/bin/mpd --no-daemon /etc/mpd.conf
|
||||||
|
# MDP will fork itself to the user defined in its config
|
||||||
|
User=root
|
||||||
|
LimitMEMLOCK=infinity
|
||||||
|
LimitRTPRIO=99
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
17
roles/music/templates/mpd_state
Normal file
17
roles/music/templates/mpd_state
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
sw_volume: 20
|
||||||
|
audio_device_state:1:Pulse
|
||||||
|
state: play
|
||||||
|
current: 0
|
||||||
|
time: 0
|
||||||
|
random: 0
|
||||||
|
repeat: 0
|
||||||
|
single: 0
|
||||||
|
consume: 0
|
||||||
|
crossfade: 0
|
||||||
|
mixrampdb: 0.000000
|
||||||
|
mixrampdelay: -1.000000
|
||||||
|
playlist_begin
|
||||||
|
song_begin: http://ice4.somafm.com/groovesalad-256-mp3
|
||||||
|
Name: SomaFM Groove Salad
|
||||||
|
song_end
|
||||||
|
playlist_end
|
|
@ -1,70 +0,0 @@
|
||||||
# {{ ansible_managed }}
|
|
||||||
|
|
||||||
server {
|
|
||||||
listen 80 default_server;
|
|
||||||
listen [::]:80 default_server;
|
|
||||||
listen 443 ssl default_server;
|
|
||||||
listen [::]:443 ssl default_server;
|
|
||||||
|
|
||||||
server_name {{ music_domain }};
|
|
||||||
|
|
||||||
{% if acme_bootstrap_certs %}
|
|
||||||
include "snippets/snakeoil.conf";
|
|
||||||
{% else %}
|
|
||||||
ssl_certificate "/var/lib/dehydrated/certs/{{ music_domain }}/fullchain.pem";
|
|
||||||
ssl_certificate_key "/var/lib/dehydrated/certs/{{ music_domain }}/privkey.pem";
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% for range in trusted_ranges %}
|
|
||||||
allow {{ range.cidr }};
|
|
||||||
{% endfor %}
|
|
||||||
deny all;
|
|
||||||
|
|
||||||
location / {
|
|
||||||
rewrite ^/(.*) https://{{ music_domain }}/trollibox/player/space?;
|
|
||||||
}
|
|
||||||
|
|
||||||
location /trollibox/ {
|
|
||||||
proxy_pass http://[::1]:3000/;
|
|
||||||
client_max_body_size 512M;
|
|
||||||
include proxy_params;
|
|
||||||
}
|
|
||||||
|
|
||||||
location ~ ^/trollibox/(.+/events)$ {
|
|
||||||
proxy_pass http://[::1]:3000/$1;
|
|
||||||
include proxy_params;
|
|
||||||
proxy_http_version 1.1;
|
|
||||||
chunked_transfer_encoding off;
|
|
||||||
add_header X-Test "123";
|
|
||||||
proxy_set_header Connection '';
|
|
||||||
proxy_buffering off;
|
|
||||||
proxy_read_timeout 7d;
|
|
||||||
}
|
|
||||||
|
|
||||||
location ~ ^/trollibox/(.+/listen)$ {
|
|
||||||
proxy_pass http://[::1]:3000/$1;
|
|
||||||
include proxy_params;
|
|
||||||
proxy_http_version 1.1;
|
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
|
||||||
proxy_set_header Connection "upgrade";
|
|
||||||
proxy_read_timeout 7d;
|
|
||||||
}
|
|
||||||
|
|
||||||
location /bobdsp/ {
|
|
||||||
proxy_pass http://[::1]:8081/;
|
|
||||||
include proxy_params;
|
|
||||||
}
|
|
||||||
|
|
||||||
location /vis/ {
|
|
||||||
allow all;
|
|
||||||
proxy_pass http://[::1]:13378/;
|
|
||||||
include proxy_params;
|
|
||||||
}
|
|
||||||
|
|
||||||
location = /vis/ {
|
|
||||||
rewrite ^(.*)$ /vis/index.html;
|
|
||||||
include proxy_params;
|
|
||||||
}
|
|
||||||
|
|
||||||
include "snippets/acme.conf";
|
|
||||||
}
|
|
49
snippets/music-nginx.j2
Normal file
49
snippets/music-nginx.j2
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
{% for range in trusted_ranges %}
|
||||||
|
allow {{ range.cidr }};
|
||||||
|
{% endfor %}
|
||||||
|
deny all;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
rewrite ^/(.*) https://{{ music_domain }}/trollibox/player/space?;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /trollibox/ {
|
||||||
|
proxy_pass http://[::1]:3000/;
|
||||||
|
include proxy_params;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ ^/trollibox/(.+/events)$ {
|
||||||
|
proxy_pass http://[::1]:3000/$1;
|
||||||
|
include proxy_params;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
chunked_transfer_encoding off;
|
||||||
|
add_header X-Test "123";
|
||||||
|
proxy_set_header Connection '';
|
||||||
|
proxy_buffering off;
|
||||||
|
proxy_read_timeout 7d;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ ^/trollibox/(.+/listen)$ {
|
||||||
|
proxy_pass http://[::1]:3000/$1;
|
||||||
|
include proxy_params;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection "upgrade";
|
||||||
|
proxy_read_timeout 7d;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /bobdsp/ {
|
||||||
|
proxy_pass http://[::1]:8081/;
|
||||||
|
include proxy_params;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /vis/ {
|
||||||
|
allow all;
|
||||||
|
proxy_pass http://[::1]:13378/;
|
||||||
|
include proxy_params;
|
||||||
|
}
|
||||||
|
|
||||||
|
location = /vis/ {
|
||||||
|
rewrite ^(.*)$ /vis/index.html;
|
||||||
|
include proxy_params;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue