Add Navidrome role

This commit is contained in:
dogeystamp 2022-04-27 17:32:52 -04:00
parent 8d9f60fbdd
commit 219cfb6e78
Signed by: dogeystamp
GPG Key ID: 7225FE3592EFFA38
5 changed files with 75 additions and 0 deletions

View File

@ -16,6 +16,7 @@ This project was largely inspired by his own [infra](https://github.com/notthebe
* Matrix Synapse
* Nginx webserver
* MediaWiki farm
* Navidrome music server
* SFTP (not really a service, included in sshd)
* Firewall (UFW)

View File

@ -0,0 +1,9 @@
- name: Run daemon-reload for Navidrome
systemd:
name: navidrome
daemon-reload: yes
- name: Restart Navidrome
service:
name: navidrome
state: restarted

View File

@ -0,0 +1,59 @@
- name: Create Navidrome user
user:
name: navidrome
home: "{{ dataroot }}/navidrome"
create_home: no
- name: Deploy SSH key for Navidrome user
ansible.posix.authorized_key:
user: navidrome
state: present
key: "{{ lookup('file', '~/.ssh/keys/{{ inventory_hostname }}_navidrome.pub')}}"
ignore_errors: yes
- name: Install Navidrome AUR package
kewlfft.aur.aur:
name: navidrome-bin
state: present
become_user: aur-build
- name: Ensure Navidrome directory is under right owner
file:
state: directory
path: "{{ dataroot }}/navidrome"
owner: navidrome
group: navidrome
recurse: yes
- name: Set Navidrome working directory
lineinfile:
dest: /usr/lib/systemd/system/navidrome.service
regexp: "^WorkingDirectory=.*"
line: "WorkingDirectory={{ dataroot }}/navidrome/"
notify: Run daemon-reload for Navidrome
- name: Set Navidrome home directory
lineinfile:
dest: /usr/lib/systemd/system/navidrome.service
regexp: "^Environment=HOME=.*"
line: "Environment=HOME={{ dataroot }}/navidrome/"
notify: Run daemon-reload for Navidrome
- name: Allow Navidrome to write in data directory
lineinfile:
dest: /usr/lib/systemd/system/navidrome.service
regexp: "^ReadWritePaths=.*"
line: "ReadWritePaths={{ dataroot }}/navidrome/"
notify: Run daemon-reload for Navidrome
- name: Configure Navidrome
template:
src: navidrome.toml.j2
dest: /etc/navidrome/navidrome.toml
notify: Restart Navidrome
- name: Start/enable Navidrome
service:
name: navidrome
state: started
enabled: yes

View File

@ -0,0 +1,2 @@
MusicFolder = "{{ dataroot }}/navidrome/mus/"
BaseUrl = "/mus"

View File

@ -68,6 +68,10 @@ http { include mime.types;
proxy_pass http://localhost:3000/ ;
}
location /mus/ {
proxy_pass http://localhost:4533/mus/ ;
}
location ~ \.php$ {
# 404
try_files $fastcgi_script_name =404;