From c770ee64aa9b0900c2e849fa0abc934cf786e307 Mon Sep 17 00:00:00 2001 From: "Tyler S. Jordan" Date: Sun, 1 Dec 2024 18:54:41 -0700 Subject: [PATCH 1/2] Add Audiobookshelf --- README.md | 1 + nas.yml | 4 ++ roles/audiobookshelf/defaults/main.yaml | 32 +++++++++++++ roles/audiobookshelf/tasks/main.yaml | 48 +++++++++++++++++++ .../media-serving/audiobookshelf.md | 17 +++++++ 5 files changed, 102 insertions(+) create mode 100644 roles/audiobookshelf/defaults/main.yaml create mode 100644 roles/audiobookshelf/tasks/main.yaml create mode 100644 website/docs/applications/media-serving/audiobookshelf.md diff --git a/README.md b/README.md index 32fefde597..83d91ad28d 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ If you have a spare domain name you can configure applications to be accessible ## Available Applications * [Airsonic](https://airsonic.github.io/) - catalog and stream music +* [Audiobookshelf](https://www.audiobookshelf.org/) - Self-hosted audiobook and podcast server * [Bazarr](https://github.com/morpheus65535/bazarr) - companion to Radarr and Sonarr for downloading subtitles * [Bitwarden](https://github.com/dani-garcia/vaultwarden) - Password Manger (Technically Vaultwarden, a lightweight implementation in Rust) * [Booksonic](https://booksonic.org/) - The selfhosted audiobook server diff --git a/nas.yml b/nas.yml index 096a7ef267..fa5736c815 100644 --- a/nas.yml +++ b/nas.yml @@ -57,6 +57,10 @@ tags: - airsonic + - role: audiobookshelf + tags: + - audiobookshelf + - role: bazarr tags: - bazarr diff --git a/roles/audiobookshelf/defaults/main.yaml b/roles/audiobookshelf/defaults/main.yaml new file mode 100644 index 0000000000..a36c3b9938 --- /dev/null +++ b/roles/audiobookshelf/defaults/main.yaml @@ -0,0 +1,32 @@ +--- +audiobookshelf_enabled: false +audiobookshelf_available_externally: false + +# directories +audiobookshelf_config_directory: "{{ docker_home }}/audiobookshelf/config" +audiobookshelf_metadata_directory: "{{ docker_home }}/audiobookshelf/metadata" +audiobookshelf_podcasts_directory: "{{ podcasts_root }}" +audiobookshelf_audiobooks_directory: "{{ audiobooks_root }}" + +# uid / gid +audiobookshelf_user_id: "0" +audiobookshelf_group_id: "0" + +# If you're paranoid, set permissions to "ro" so audiobookshelf won't ever be able to +# delete your files +audiobookshelf_podcasts_permissions: "rw" +audiobookshelf_audiobooks_permissions: "rw" + +# network +audiobookshelf_hostname: "audiobookshelf" + +# docker +audiobookshelf_container_name: "audiobookshelf" +audiobookshelf_image_name: "ghcr.io/advplyr/audiobookshelf" +audiobookshelf_image_version: "latest" + +# specs +audiobookshelf_memory: "2g" + +# see https://hub.docker.com/r/linuxserver/audiobookshelf for details on this setting +audiobookshelf_version: "docker" diff --git a/roles/audiobookshelf/tasks/main.yaml b/roles/audiobookshelf/tasks/main.yaml new file mode 100644 index 0000000000..40a8e7b3c8 --- /dev/null +++ b/roles/audiobookshelf/tasks/main.yaml @@ -0,0 +1,48 @@ +- name: Start Audiobookshelf + block: + - name: Create Audiobookshelf Directories + ansible.builtin.file: + path: "{{ item }}" + state: directory + with_items: + - "{{ audiobookshelf_config_directory }}" + - "{{ audiobookshelf_metadata_directory }}" + + - name: Create Audiobookshelf Docker Container + community.docker.docker_container: + name: "{{ audiobookshelf_container_name }}" + image: "{{ audiobookshelf_image_name }}:{{ audiobookshelf_image_version }}" + pull: true + volumes: + - "{{ audiobookshelf_config_directory }}:/config:rw" + - "{{ audiobookshelf_metadata_directory }}:/metadata:rw" + - "{{ audiobookshelf_podcasts_directory }}:/podcasts:{{ audiobookshelf_podcasts_permissions }}" + - "{{ audiobookshelf_audiobooks_directory }}:/audiobooks:{{ audiobookshelf_audiobooks_permissions }}" + env: + TZ: "{{ ansible_nas_timezone }}" + PUID: "{{ audiobookshelf_user_id }}" + PGID: "{{ audiobookshelf_group_id }}" + VERSION: "{{ audiobookshelf_version }}" + restart_policy: unless-stopped + memory: "{{ audiobookshelf_memory }}" + labels: + traefik.enable: "{{ audiobookshelf_available_externally | string }}" + traefik.http.routers.audiobookshelf.rule: "Host(`{{ audiobookshelf_hostname }}.{{ ansible_nas_domain }}`)" + traefik.http.routers.audiobookshelf.tls.certresolver: "letsencrypt" + traefik.http.routers.audiobookshelf.tls.domains[0].main: "{{ ansible_nas_domain }}" + traefik.http.routers.audiobookshelf.tls.domains[0].sans: "*.{{ ansible_nas_domain }}" + traefik.http.services.audiobookshelf.loadbalancer.server.port: "13378" + homepage.group: Media + homepage.name: Audiobookshelf + homepage.icon: audiobookshelf + homepage.href: http://{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}:13378 + homepage.description: Media server + when: audiobookshelf_enabled is true + +- name: Stop Audiobookshelf + block: + - name: Stop Audiobookshelf + community.docker.docker_container: + name: "{{ audiobookshelf_container_name }}" + state: absent + when: audiobookshelf_enabled is false diff --git a/website/docs/applications/media-serving/audiobookshelf.md b/website/docs/applications/media-serving/audiobookshelf.md new file mode 100644 index 0000000000..fde803284e --- /dev/null +++ b/website/docs/applications/media-serving/audiobookshelf.md @@ -0,0 +1,17 @@ +--- +title: "Audiobookshelf" +--- + +Homepage: [https://audiobookshelf.org/](https://audiobookshelf.org/) + +Audiobookshelf is an open-source self-hosted media server for your audiobooks and podcasts. + +Fully Open-Source. You can find the code on [GitHub](https://github.com/advplyr/audiobookshelf) + +Get the Android app on [Google Play](https://play.google.com/store/apps/details?id=com.audiobookshelf.app). iOS app is in beta. + +## Usage + +Set `audiobookshelf_enabled: true` in your `inventories//group_vars/nas.yml` file. + +The Audiobookshelf web interface can be found at [http://ansible_nas_host_or_ip:13378](http://ansible_nas_host_or_ip:13378). From 73ea064e302926b36c80c0c7697da40d0f5c3515 Mon Sep 17 00:00:00 2001 From: "Tyler S. Jordan" Date: Mon, 2 Dec 2024 01:16:17 -0700 Subject: [PATCH 2/2] Specify Audiobookshelf port properly --- roles/audiobookshelf/defaults/main.yaml | 1 + roles/audiobookshelf/tasks/main.yaml | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/roles/audiobookshelf/defaults/main.yaml b/roles/audiobookshelf/defaults/main.yaml index a36c3b9938..8b27644333 100644 --- a/roles/audiobookshelf/defaults/main.yaml +++ b/roles/audiobookshelf/defaults/main.yaml @@ -19,6 +19,7 @@ audiobookshelf_audiobooks_permissions: "rw" # network audiobookshelf_hostname: "audiobookshelf" +audiobookshelf_port: "13378" # docker audiobookshelf_container_name: "audiobookshelf" diff --git a/roles/audiobookshelf/tasks/main.yaml b/roles/audiobookshelf/tasks/main.yaml index 40a8e7b3c8..13a46147b0 100644 --- a/roles/audiobookshelf/tasks/main.yaml +++ b/roles/audiobookshelf/tasks/main.yaml @@ -18,6 +18,8 @@ - "{{ audiobookshelf_metadata_directory }}:/metadata:rw" - "{{ audiobookshelf_podcasts_directory }}:/podcasts:{{ audiobookshelf_podcasts_permissions }}" - "{{ audiobookshelf_audiobooks_directory }}:/audiobooks:{{ audiobookshelf_audiobooks_permissions }}" + ports: + - "{{ audiobookshelf_port }}:80" env: TZ: "{{ ansible_nas_timezone }}" PUID: "{{ audiobookshelf_user_id }}" @@ -31,12 +33,12 @@ traefik.http.routers.audiobookshelf.tls.certresolver: "letsencrypt" traefik.http.routers.audiobookshelf.tls.domains[0].main: "{{ ansible_nas_domain }}" traefik.http.routers.audiobookshelf.tls.domains[0].sans: "*.{{ ansible_nas_domain }}" - traefik.http.services.audiobookshelf.loadbalancer.server.port: "13378" + traefik.http.services.audiobookshelf.loadbalancer.server.port: "80" homepage.group: Media homepage.name: Audiobookshelf homepage.icon: audiobookshelf - homepage.href: http://{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}:13378 - homepage.description: Media server + homepage.href: "http://{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}:{{ audiobookshelf_port }}" + homepage.description: Self-hosted audiobook and podcast server when: audiobookshelf_enabled is true - name: Stop Audiobookshelf