music: Add soundboard
This commit is contained in:
parent
97a4e95ca8
commit
2e47c6744f
7 changed files with 141 additions and 0 deletions
|
@ -17,3 +17,9 @@
|
||||||
name: librespot
|
name: librespot
|
||||||
state: restarted
|
state: restarted
|
||||||
daemon_reload: true
|
daemon_reload: true
|
||||||
|
|
||||||
|
- name: restart soundboard
|
||||||
|
systemd:
|
||||||
|
name: soundboard
|
||||||
|
state: restarted
|
||||||
|
daemon_reload: true
|
||||||
|
|
|
@ -8,6 +8,9 @@
|
||||||
- tags: music_librespot
|
- tags: music_librespot
|
||||||
import_tasks: librespot.yaml
|
import_tasks: librespot.yaml
|
||||||
|
|
||||||
|
- tags: music_soundboard
|
||||||
|
import_tasks: soundboard.yaml
|
||||||
|
|
||||||
- tags: music
|
- tags: music
|
||||||
block:
|
block:
|
||||||
- name: Install nginx
|
- name: Install nginx
|
||||||
|
|
72
roles/music/tasks/soundboard.yaml
Normal file
72
roles/music/tasks/soundboard.yaml
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
---
|
||||||
|
- name: Install dependencies
|
||||||
|
apt:
|
||||||
|
name: virtualenv
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Clone soundboard source
|
||||||
|
git:
|
||||||
|
repo: https://github.com/polyfloyd/mqtt-soundboard.git
|
||||||
|
version: main
|
||||||
|
dest: /opt/soundboard
|
||||||
|
accept_hostkey: yes
|
||||||
|
notify: restart soundboard
|
||||||
|
|
||||||
|
- name: Create virtualenv
|
||||||
|
command: virtualenv /opt/soundboard/.venv
|
||||||
|
args:
|
||||||
|
creates: /opt/soundboard/.venv
|
||||||
|
|
||||||
|
- name: Install Python dependencies
|
||||||
|
shell: . .venv/bin/activate && pip install -r requirements.txt
|
||||||
|
args:
|
||||||
|
chdir: /opt/soundboard
|
||||||
|
|
||||||
|
- name: Install soundboard config file
|
||||||
|
template:
|
||||||
|
src: soundboard.yaml
|
||||||
|
dest: /etc/soundboard.yaml
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0644
|
||||||
|
notify: restart soundboard
|
||||||
|
|
||||||
|
- name: Install soundboard service file
|
||||||
|
template:
|
||||||
|
src: soundboard.service
|
||||||
|
dest: /etc/systemd/system/soundboard.service
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0644
|
||||||
|
notify: restart soundboard
|
||||||
|
|
||||||
|
- name: Enable soundboard
|
||||||
|
systemd:
|
||||||
|
name: soundboard
|
||||||
|
state: started
|
||||||
|
enabled: true
|
||||||
|
daemon_reload: true
|
||||||
|
|
||||||
|
- name: Install shutdown sound script
|
||||||
|
template:
|
||||||
|
src: shutdown-sound.sh
|
||||||
|
dest: /opt/shutdown-sound.sh
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0644
|
||||||
|
|
||||||
|
- name: Install shutdown sound service
|
||||||
|
template:
|
||||||
|
src: shutdown-sound.service
|
||||||
|
dest: /etc/systemd/system/shutdown-sound.service
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0644
|
||||||
|
notify: daemon reload
|
||||||
|
|
||||||
|
- name: Enable shutdown-sound
|
||||||
|
systemd:
|
||||||
|
name: shutdown-sound
|
||||||
|
state: started
|
||||||
|
enabled: true
|
||||||
|
daemon_reload: true
|
16
roles/music/templates/shutdown-sound.service
Normal file
16
roles/music/templates/shutdown-sound.service
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
# Managed by Ansible
|
||||||
|
|
||||||
|
[Unit]
|
||||||
|
Description=Goodbye
|
||||||
|
Requires=mpd.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=/bin/true
|
||||||
|
ExecStop=/opt/shutdown.sh
|
||||||
|
RemainAfterExit=true
|
||||||
|
User=audio
|
||||||
|
Group=audio
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
8
roles/music/templates/shutdown-sound.sh
Normal file
8
roles/music/templates/shutdown-sound.sh
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Managed by Ansible
|
||||||
|
|
||||||
|
systemctl stop trollibox.service
|
||||||
|
mpc clear
|
||||||
|
|
||||||
|
su audio -c 'mplayer -volume 10 -ao jack:name=MPlayer /opt/sounds/shutdown.mp3'
|
15
roles/music/templates/soundboard.service
Normal file
15
roles/music/templates/soundboard.service
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
# Managed by Ansible
|
||||||
|
|
||||||
|
[Unit]
|
||||||
|
Description=MQTT Soundboard
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
ExecStart=/opt/soundboard/.venv/bin/python /opt/soundboard/soundboard.py /etc/soundboard.yaml
|
||||||
|
Restart=always
|
||||||
|
RestartSec=10
|
||||||
|
User=root
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
21
roles/music/templates/soundboard.yaml
Normal file
21
roles/music/templates/soundboard.yaml
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
loglevel: INFO
|
||||||
|
|
||||||
|
mqtt:
|
||||||
|
host: mqtt.bitlair.nl
|
||||||
|
|
||||||
|
sounds:
|
||||||
|
directory: /opt/sounds
|
||||||
|
play_cmd: "mplayer -volume 10 -ao jack:name=MPlayer %s"
|
||||||
|
topic: bitlair/soundboard
|
||||||
|
|
||||||
|
aliases:
|
||||||
|
- sound: space_open
|
||||||
|
topic: bitlair/state
|
||||||
|
value: open
|
||||||
|
- sound: space_close
|
||||||
|
topic: bitlair/state
|
||||||
|
value: close
|
||||||
|
- sound: doorbell
|
||||||
|
topic: bitlair/doorduino/doorbell
|
||||||
|
- sound: nomunnie
|
||||||
|
topic: bitlair/bank/shame
|
Loading…
Add table
Reference in a new issue