Compare commits
3 commits
cb7ab2782a
...
2e47c6744f
Author | SHA1 | Date | |
---|---|---|---|
2e47c6744f | |||
97a4e95ca8 | |||
b1add6ce2c |
19 changed files with 195 additions and 38 deletions
|
@ -1,6 +1,5 @@
|
||||||
---
|
---
|
||||||
- hosts: bank
|
- hosts: bank
|
||||||
vars:
|
|
||||||
roles:
|
roles:
|
||||||
- common
|
- common
|
||||||
- bank
|
- bank
|
||||||
|
|
4
common.yaml
Normal file
4
common.yaml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
- hosts: debian
|
||||||
|
roles:
|
||||||
|
- common
|
1
group_vars/mqtt_internal.yaml
Normal file
1
group_vars/mqtt_internal.yaml
Normal file
|
@ -0,0 +1 @@
|
||||||
|
mqtt_internal_public_host: bitlair.nl
|
3
group_vars/music.yaml
Normal file
3
group_vars/music.yaml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
music_domain: music.bitlair.nl
|
||||||
|
acme_san_domains:
|
||||||
|
- [ music.bitlair.nl ]
|
11
hosts
11
hosts
|
@ -1,11 +0,0 @@
|
||||||
[bank]
|
|
||||||
bank.bitlair.nl
|
|
||||||
|
|
||||||
[bar]
|
|
||||||
bank-pi.bitlair.nl
|
|
||||||
|
|
||||||
[mqtt_internal]
|
|
||||||
mqtt.bitlair.nl
|
|
||||||
|
|
||||||
[music]
|
|
||||||
music.bitlair.nl
|
|
25
hosts.yaml
Normal file
25
hosts.yaml
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
all:
|
||||||
|
children:
|
||||||
|
raspi:
|
||||||
|
hosts:
|
||||||
|
bank-pi.bitlair.nl:
|
||||||
|
debian:
|
||||||
|
children:
|
||||||
|
bank:
|
||||||
|
hosts:
|
||||||
|
bank.bitlair.nl:
|
||||||
|
git:
|
||||||
|
hosts:
|
||||||
|
git.bitlair.nl:
|
||||||
|
lights:
|
||||||
|
hosts:
|
||||||
|
lights.bitlair.nl:
|
||||||
|
mqtt_internal:
|
||||||
|
hosts:
|
||||||
|
mqtt.bitlair.nl:
|
||||||
|
music:
|
||||||
|
hosts:
|
||||||
|
music.bitlair.nl:
|
||||||
|
www:
|
||||||
|
hosts:
|
||||||
|
cyber.bitlair.nl:
|
|
@ -1,7 +1,5 @@
|
||||||
---
|
---
|
||||||
- hosts: mqtt_internal
|
- hosts: mqtt_internal
|
||||||
vars:
|
|
||||||
mqtt_internal_public_host: bitlair.nl
|
|
||||||
roles:
|
roles:
|
||||||
- common
|
- common
|
||||||
- mqtt-internal
|
- mqtt-internal
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
---
|
---
|
||||||
- hosts: music
|
- hosts: music
|
||||||
vars:
|
|
||||||
music_domain: music.bitlair.nl
|
|
||||||
acme_san_domains:
|
|
||||||
- [ music.bitlair.nl ]
|
|
||||||
roles:
|
roles:
|
||||||
- common
|
- common
|
||||||
- acme
|
- acme
|
||||||
|
|
|
@ -2,5 +2,6 @@
|
||||||
|
|
||||||
location /.well-known/acme-challenge {
|
location /.well-known/acme-challenge {
|
||||||
allow all;
|
allow all;
|
||||||
|
auth_basic off;
|
||||||
alias /var/lib/dehydrated/acme-challenges;
|
alias /var/lib/dehydrated/acme-challenges;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
lineinfile:
|
lineinfile:
|
||||||
path: /etc/bash.bashrc
|
path: /etc/bash.bashrc
|
||||||
insertafter: EOF
|
insertafter: EOF
|
||||||
regexp: "^source /usr/share/doc/fzf/{{ item }}"
|
regexp: "^source /usr/share/doc/fzf/examples/{{ item }}"
|
||||||
line: "source /usr/share/doc/fzf/examples/{{ item }} # Managed by Ansible"
|
line: "source /usr/share/doc/fzf/examples/{{ item }} # Managed by Ansible"
|
||||||
with_items:
|
with_items:
|
||||||
- key-bindings.bash
|
- key-bindings.bash
|
||||||
|
@ -77,12 +77,15 @@
|
||||||
- ipv6
|
- ipv6
|
||||||
notify: persist iptables
|
notify: persist iptables
|
||||||
|
|
||||||
- name: Allow IPv6 ICMP
|
- name: Allow ICMP
|
||||||
iptables:
|
iptables:
|
||||||
chain: INPUT
|
chain: INPUT
|
||||||
protocol: ipv6-icmp
|
protocol: "{{ item.proto }}"
|
||||||
jump: ACCEPT
|
jump: ACCEPT
|
||||||
ip_version: ipv6
|
ip_version: "{{ item.ip }}"
|
||||||
|
with_items:
|
||||||
|
- { ip: ipv4, proto: icmp }
|
||||||
|
- { ip: ipv6, proto: ipv6-icmp }
|
||||||
notify: persist iptables
|
notify: persist iptables
|
||||||
|
|
||||||
- name: Allow related and established connections
|
- name: Allow related and established connections
|
||||||
|
|
|
@ -5,17 +5,14 @@
|
||||||
state: present
|
state: present
|
||||||
when: network_br
|
when: network_br
|
||||||
|
|
||||||
- lineinfile:
|
- name: Configure sysctl.conf
|
||||||
|
lineinfile:
|
||||||
path: /etc/sysctl.conf
|
path: /etc/sysctl.conf
|
||||||
regexp: ^#?net.ipv4.ip_forward
|
regexp: "^#?{{ item.k }}"
|
||||||
line: "net.ipv4.ip_forward=1 # Managed by Ansible"
|
line: "{{ item.k }}={{ item.v }} # Managed by Ansible"
|
||||||
notify: reboot
|
with_items:
|
||||||
when: network_br
|
- { k: net.ipv4.ip_forward, v: "1" }
|
||||||
|
- { k: net.ipv6.conf.all.forwarding, v: "1" }
|
||||||
- lineinfile:
|
|
||||||
path: /etc/sysctl.conf
|
|
||||||
regexp: ^#?net.ipv6.conf.all.forwarding
|
|
||||||
line: "net.ipv6.conf.all.forwarding=1 # Managed by Ansible"
|
|
||||||
notify: reboot
|
notify: reboot
|
||||||
when: network_br
|
when: network_br
|
||||||
|
|
||||||
|
|
|
@ -18,20 +18,20 @@ iface eth0 inet manual
|
||||||
|
|
||||||
auto br0
|
auto br0
|
||||||
iface br0 inet static
|
iface br0 inet static
|
||||||
address {{ network_static.address_v4 }}
|
address {{ network_address_v4 }}
|
||||||
gateway {{ network_static.gateway_v4 }}
|
gateway {{ network_gateway_v4 }}
|
||||||
bridge_ports eth0
|
bridge_ports eth0
|
||||||
|
|
||||||
iface br0 inet6 auto
|
iface br0 inet6 auto
|
||||||
up echo -n 0 > /sys/devices/virtual/net/br0/bridge/multicast_snooping
|
up echo -n 0 > /sys/devices/virtual/net/br0/bridge/multicast_snooping
|
||||||
up ip -6 addr add {{ network_static.address_v6 }} dev br0
|
up ip -6 addr add {{ network_address_v6 }} dev br0
|
||||||
up ip -6 route add default via {{ network_static.gateway_v6 }} dev br0
|
up ip -6 route add default via {{ network_gateway_v6 }} dev br0
|
||||||
bridge_stp on
|
bridge_stp on
|
||||||
|
|
||||||
{% elif network_static %}
|
{% elif network_static %}
|
||||||
iface eth0 inet static
|
iface eth0 inet static
|
||||||
address {{ network_static.address_v4 }}
|
address {{ network_address_v4 }}
|
||||||
gateway {{ network_static.gateway_v4 }}
|
gateway {{ network_gateway_v4 }}
|
||||||
|
|
||||||
{% else %}
|
{% else %}
|
||||||
iface eth0 inet dhcp
|
iface eth0 inet dhcp
|
||||||
|
|
|
@ -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