feat: Initial release

Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
Julien Riou 2025-03-03 14:06:02 +01:00
parent ac41069e13
commit 0386c756b9
Signed by: jriou
GPG key ID: 9A099EDA51316854
7 changed files with 151 additions and 2 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
venv

View file

@ -1,3 +1,46 @@
# ansible-role-navidrome # Ansible Role Navidrome
Ansible role to manage a Navidrome instance Ansible role to manage a [Navidrome](https://github.com/navidrome/navidrome) instance.
## Installation
Clone the repository in your local Ansible roles directory:
```
git clone https://git.riou.xyz/jriou/ansible-role-forgejo.git ~/.ansible/roles/navidrome
```
See [Storing and finding
roles](https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_reuse_roles.html#storing-and-finding-roles).
## Configuration
See [Variable
precedence](https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_variables.html#ansible-variable-precedence)
to find where you should put your own variables.
See list of [default
variables](https://git.riou.xyz/jriou/ansible-role-navidrome/src/branch/main/defaults/main.yml).
## Usage
Example of a basic navidrome.yml playbook:
```yaml
hosts:
- navidrome
roles:
- navidrome
```
Then run the playbook:
```
ansible-playbook navidrome.yml
```
## Donate
As we all love FOSS, you should consider sponsoring the
[Navidrome](https://github.com/navidrome/navidrome) project.

14
defaults/main.yml Normal file
View file

@ -0,0 +1,14 @@
---
navidrome_version: 0.54.5
navidrome_arch: amd64
navidrome_user: navidrome
navidrome_group: navidrome
navidrome_music_folder: /opt/navidrome/music
navidrome_data_folder: /var/lib/navidrome
navidrome_cache_folder: "{{ navidrome_data_folder }}/cache"
navidrome_manage_iptables: false
navidrome_allowed_sources: []
navidrome_address: localhost
navidrome_port: 4533
navidrome_enable_insights_collector: false
# navidrome_base_url:

14
handlers/main.yml Normal file
View file

@ -0,0 +1,14 @@
---
- name: Reload systemd
ansible.builtin.systemd_service:
daemon_reload: true
- name: Restart navidrome
ansible.builtin.service:
name: navidrome
state: restarted
- name: Save iptables
ansible.builtin.command:
cmd: netfilter-persistent save
changed_when: true

62
tasks/main.yml Normal file
View file

@ -0,0 +1,62 @@
---
- name: Install package
ansible.builtin.apt:
deb: "https://github.com/navidrome/navidrome/releases/download/v{{ navidrome_version }}/navidrome_{{ navidrome_version }}_linux_{{ navidrome_arch }}.deb"
- name: Create directories
ansible.builtin.file:
state: directory
path: "{{ item }}"
owner: "{{ navidrome_user }}"
group: "{{ navidrome_group }}"
mode: "0755"
loop:
- "{{ navidrome_music_folder }}"
- "{{ navidrome_data_folder }}"
- "{{ navidrome_cache_folder }}"
- name: Create configuration file
ansible.builtin.template:
src: navidrome.toml.j2
dest: /etc/navidrome/navidrome.toml
owner: "{{ navidrome_user }}"
group: "{{ navidrome_group }}"
mode: "0644"
notify:
- Restart navidrome
- name: Create systemd override directory
ansible.builtin.file:
state: directory
path: /etc/systemd/system/navidrome.service.d
owner: root
group: root
mode: "0755"
- name: Add systemd override
ansible.builtin.template:
src: override.conf.j2
dest: /etc/systemd/system/navidrome.service.d/override.conf
owner: root
group: root
mode: "0755"
notify:
- Reload systemd
- Restart navidrome
- name: Start service
ansible.builtin.service:
name: navidrome
state: started
- name: Manage iptables
ansible.builtin.iptables:
chain: INPUT
protocol: tcp
source: "{{ item }}"
destination_port: "{{ navidrome_port }}"
jump: ACCEPT
comment: navidrome
loop: "{{ navidrome_allowed_sources }}"
notify: Save iptables
when: navidrome_manage_iptables

View file

@ -0,0 +1,10 @@
{{ ansible_managed | comment }}
MusicFolder = "{{ navidrome_music_folder }}"
DataFolder = "{{ navidrome_data_folder }}"
CacheFolder = "{{ navidrome_cache_folder }}"
Address = "{{ navidrome_address }}"
Port = "{{ navidrome_port }}"
EnableInsightsCollector = "{{ navidrome_enable_insights_collector }}"
{% if navidrome_base_url is defined %}
BaseUrl = "{{ navidrome_base_url }}"
{% endif %}

View file

@ -0,0 +1,5 @@
{{ ansible_managed | comment }}
[Service]
User={{ navidrome_user }}
WorkingDirectory={{ navidrome_data_folder }}
ReadWritePaths={{ navidrome_data_folder }}