audiobookshelf: Initial version of role

This commit is contained in:
Timo Makinen 2025-03-01 19:10:16 +00:00
parent a793f59a33
commit 4c7c0e3261
5 changed files with 132 additions and 0 deletions

View file

@ -0,0 +1,4 @@
METADATA_PATH=/srv/audiobookshelf/metadata
CONFIG_PATH=/srv/audiobookshelf/config
PORT=13378
HOST=127.0.0.1

View file

@ -0,0 +1,30 @@
= Preparing files for upload =
== Filenames ==
Filenames should always contain track number (and optionally disc number) with leading zeros first and subtitle after that. Few exmaples:
```
01. Luku.mp3
01. Osa.mp3
CD 1 - 01.mp3
```
Directory should also contain `cover.jpg` with book cover picture and `desc.txt` containing book description.
== Metadata (id3 tags) ==
First clear old tags then set new ones:
```
id3v2 -D "01. Osa.mp3"
id3v2 \
--TPE1 "Douglas Adams" \
--TALB "$(echo 'Linnunradan käsikirja liftareille' | iconv -f utf-8 -t iso-8859-1)" \
--TCOM "$(echo 'Heikki Kinnunen,Pekka Autiovuori,Yrjö Järvinen,Martti Järvinen,Esa Saario,Kauko Helavirta,Aila Svedberg' | iconv -f utf-8 -t iso-8859-1)" \
--TLAN "fi" \
--TPUB "Yleisradio" \
--TYER 1984 \
--genre "Science Fiction/Fiction/Humor" \
"01. Osa.mp3"
```

View file

@ -0,0 +1,5 @@
---
- name: Restart audiobookshelf
ansible.builtin.service:
name: audiobookshelf
state: restarted

View file

@ -0,0 +1,3 @@
---
dependencies:
- {role: nginx}

View file

@ -0,0 +1,90 @@
---
- name: Enable repository
ansible.builtin.yum_repository:
name: audiobookshelf
baseurl: https://raw.githubusercontent.com/lkiesow/audiobookshelf-rpm/el$releasever/
description: Audiobookshelf el$releasever repository
gpgcheck: true
gpgkey: https://raw.githubusercontent.com/lkiesow/audiobookshelf-rpm/main/audiobookshelf-rpm.key
enabled: true
- name: Install packcages
ansible.builtin.package:
name: audiobookshelf
state: present
- name: Create data directories
ansible.builtin.file:
path: "{{ item }}"
state: directory
mode: "0770"
owner: root
group: audiobookshelf
with_items:
- /export/audiobookshelf
- /export/audiobookshelf/audiobooks
- /export/audiobookshelf/config
- /export/audiobookshelf/metadata
- /export/audiobookshelf/podcasts
- /export/audiobookshelf/radioplays
- name: Link data directory
ansible.builtin.file:
dest: /srv/audiobookshelf
src: /export/audiobookshelf
state: link
owner: root
group: "{{ ansible_wheel }}"
follow: false
- name: Copy naming instructions
ansible.builtin.copy:
dest: /srv/audiobookshelf/audiobooks/README.md
src: meta.md
mode: "0644"
owner: root
group: "{{ ansible_wheel }}"
- name: Copy service config
ansible.builtin.copy:
dest: /etc/default/audiobookshelf
src: audiobookshelf.default
mode: "0644"
owner: root
group: "{{ ansible_wheel }}"
notify: Restart audiobookshelf
- name: Enable service
ansible.builtin.service:
name: audiobookshelf
state: started
enabled: true
- name: Allow nginx to connect audiobookshelf
ansible.posix.seboolean:
name: httpd_can_network_connect
state: true
persistent: true
- name: Copy nginx config
ansible.builtin.copy:
dest: "/etc/nginx/conf.d/{{ inventory_hostname }}/audiobookshelf.conf"
content: |
location / {
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host audiobooks.foo.sh;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
proxy_pass http://127.0.0.1:13378/;
location /audiobookshelf/api/upload {
# increase size to allow uploads
client_max_body_size 10g;
proxy_pass http://127.0.0.1:13378/api/upload;
}
}
mode: "0644"
owner: root
group: "{{ ansible_wheel }}"
notify: Restart nginx