diff --git a/README.md b/README.md index 89cfffc..f883d63 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/roles/services/navidrome/handlers/main.yml b/roles/services/navidrome/handlers/main.yml new file mode 100644 index 0000000..b3dd57b --- /dev/null +++ b/roles/services/navidrome/handlers/main.yml @@ -0,0 +1,9 @@ +- name: Run daemon-reload for Navidrome + systemd: + name: navidrome + daemon-reload: yes + +- name: Restart Navidrome + service: + name: navidrome + state: restarted diff --git a/roles/services/navidrome/tasks/main.yml b/roles/services/navidrome/tasks/main.yml new file mode 100644 index 0000000..6c46b24 --- /dev/null +++ b/roles/services/navidrome/tasks/main.yml @@ -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 diff --git a/roles/services/navidrome/templates/navidrome.toml.j2 b/roles/services/navidrome/templates/navidrome.toml.j2 new file mode 100644 index 0000000..47003a1 --- /dev/null +++ b/roles/services/navidrome/templates/navidrome.toml.j2 @@ -0,0 +1,2 @@ +MusicFolder = "{{ dataroot }}/navidrome/mus/" +BaseUrl = "/mus" diff --git a/roles/services/webserver/templates/nginx.conf.j2 b/roles/services/webserver/templates/nginx.conf.j2 index 6f78c1c..3f65f02 100644 --- a/roles/services/webserver/templates/nginx.conf.j2 +++ b/roles/services/webserver/templates/nginx.conf.j2 @@ -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;