From c09ff81fcfa7cd0cf36945718800aa856dfb7264 Mon Sep 17 00:00:00 2001 From: eniad Date: Sat, 18 Nov 2023 20:46:04 -0500 Subject: [PATCH 1/4] add Kavita --- README.md | 1 + nas.yml | 4 ++ roles/kavita/defaults/main.yml | 25 +++++++++++ roles/kavita/molecule/default/molecule.yml | 6 +++ roles/kavita/molecule/default/side_effect.yml | 10 +++++ roles/kavita/molecule/default/verify.yml | 18 ++++++++ .../molecule/default/verify_stopped.yml | 18 ++++++++ roles/kavita/tasks/main.yml | 43 +++++++++++++++++++ .../docs/applications/media-serving/kavita.md | 17 ++++++++ 9 files changed, 142 insertions(+) create mode 100644 roles/kavita/defaults/main.yml create mode 100644 roles/kavita/molecule/default/molecule.yml create mode 100644 roles/kavita/molecule/default/side_effect.yml create mode 100644 roles/kavita/molecule/default/verify.yml create mode 100644 roles/kavita/molecule/default/verify_stopped.yml create mode 100644 roles/kavita/tasks/main.yml create mode 100644 website/docs/applications/media-serving/kavita.md diff --git a/README.md b/README.md index c2ac174cf9..9fd3619be2 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,7 @@ If you have a spare domain name you can configure applications to be accessible * [Jackett](https://github.com/Jackett/Jackett) - API Support for your favorite torrent trackers * [Jellyfin](https://jellyfin.github.io) - The Free Software Media System * [Joomla](https://www.joomla.org/) - Open source content management system +* [Kavita](https://www.kavitareader.com/) - Digital library which supports a vast array of file formats * [Komga](https://komga.org/) - a media server for your comics, mangas, BDs and magazines * [Krusader](https://krusader.org/) - Twin panel file management for your desktop * [Lidarr](https://github.com/lidarr/Lidarr) - Music collection manager for Usenet and BitTorrent users diff --git a/nas.yml b/nas.yml index d5680f2a05..0922570907 100644 --- a/nas.yml +++ b/nas.yml @@ -194,6 +194,10 @@ tags: - joomla + - role: kavita + tags: + - kavita + - role: komga tags: - komga diff --git a/roles/kavita/defaults/main.yml b/roles/kavita/defaults/main.yml new file mode 100644 index 0000000000..ebf8336aad --- /dev/null +++ b/roles/kavita/defaults/main.yml @@ -0,0 +1,25 @@ +--- +kavita_enabled: false +kavita_available_externally: false + +# uid / gid +kavita_user_id: "1000" +kavita_group_id: "1000" + +# directories +kavita_data_directory: "{{ docker_home }}/kavita" +kavita_books_directory: "{{ books_root }}" +kavita_comics_directory: "{{ comics_root }}" + +# image +kavita_image: "linuxserver/kavita" + +# network +kavita_port: "5002" +kavita_hostname: "kavita" + +# specs +kavita_memory: 1g + +# docker +kavita_container_name: kavita diff --git a/roles/kavita/molecule/default/molecule.yml b/roles/kavita/molecule/default/molecule.yml new file mode 100644 index 0000000000..0fe89fb0dd --- /dev/null +++ b/roles/kavita/molecule/default/molecule.yml @@ -0,0 +1,6 @@ +--- +provisioner: + inventory: + group_vars: + all: + kavita_enabled: true diff --git a/roles/kavita/molecule/default/side_effect.yml b/roles/kavita/molecule/default/side_effect.yml new file mode 100644 index 0000000000..4729485d36 --- /dev/null +++ b/roles/kavita/molecule/default/side_effect.yml @@ -0,0 +1,10 @@ +--- +- name: Stop + hosts: all + become: true + tasks: + - name: "Include {{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }} role" + include_role: + name: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }}" + vars: + kavita_enabled: false diff --git a/roles/kavita/molecule/default/verify.yml b/roles/kavita/molecule/default/verify.yml new file mode 100644 index 0000000000..af6c754ec4 --- /dev/null +++ b/roles/kavita/molecule/default/verify.yml @@ -0,0 +1,18 @@ +--- +- name: Verify + hosts: all + gather_facts: false + tasks: + - include_vars: + file: ../../defaults/main.yml + + - name: Get container state + docker_container_info: + name: "{{ kavita_container_name }}" + register: result + + - name: Check Kavita is running + assert: + that: + - result.container['State']['Status'] == "running" + - result.container['State']['Restarting'] == false diff --git a/roles/kavita/molecule/default/verify_stopped.yml b/roles/kavita/molecule/default/verify_stopped.yml new file mode 100644 index 0000000000..e4280dc0cb --- /dev/null +++ b/roles/kavita/molecule/default/verify_stopped.yml @@ -0,0 +1,18 @@ +--- +- name: Verify + hosts: all + gather_facts: false + tasks: + - include_vars: + file: ../../defaults/main.yml + + - name: Try and stop and remove Kavita + docker_container: + name: "{{ kavita_container_name }}" + state: absent + register: result + + - name: Check Kavita is stopped + assert: + that: + - not result.changed diff --git a/roles/kavita/tasks/main.yml b/roles/kavita/tasks/main.yml new file mode 100644 index 0000000000..7f1cc58c2d --- /dev/null +++ b/roles/kavita/tasks/main.yml @@ -0,0 +1,43 @@ +--- +- name: Start Kavita + block: + - name: Create Kavita Directories + file: + path: "{{ item }}" + state: directory + with_items: + - "{{ kavita_data_directory }}/config" + + - name: Kavita Docker Container + docker_container: + name: "{{ kavita_container_name }}" + image: "{{ kavita_image }}" + pull: true + volumes: + - "{{ kavita_data_directory }}/config:/kavita/config" + - "{{ kavita_comics_directory }}:/comics" + - "{{ kavita_books_directory }}:/books" + env: + TZ: "{{ ansible_nas_timezone }}" + PUID: "{{ kavita_user_id }}" + PGID: "{{ kavita_group_id }}" + ports: + - "{{ kavita_port }}:5000" + restart_policy: unless-stopped + memory: "{{ kavita_memory }}" + labels: + traefik.enable: "{{ kavita_available_externally | string }}" + traefik.http.routers.kavita.rule: "Host(`kavita.{{ ansible_nas_domain }}`)" + traefik.http.routers.kavita.tls.certresolver: "letsencrypt" + traefik.http.routers.kavita.tls.domains[0].main: "{{ ansible_nas_domain }}" + traefik.http.routers.kavita.tls.domains[0].sans: "*.{{ ansible_nas_domain }}" + traefik.http.services.kavita.loadbalancer.server.port: "5002" + when: kavita_enabled is true + +- name: Stop Kavita + block: + - name: Stop Kavita + docker_container: + name: "{{ kavita_container_name }}" + state: absent + when: kavita_enabled is false diff --git a/website/docs/applications/media-serving/kavita.md b/website/docs/applications/media-serving/kavita.md new file mode 100644 index 0000000000..d1ab43f472 --- /dev/null +++ b/website/docs/applications/media-serving/kavita.md @@ -0,0 +1,17 @@ +--- +title: "Kavita" +--- + +Homepage: + +Github: + +Docker Image: + +Lighting fast with a slick design, Kavita is a rocket fueled self-hosted digital library which supports a vast array of file formats. Install to start reading and share your server with your friends. + +## Usage + +Set `kavita_enabled: true` in your `inventories//nas.yml` file. + +Access the webui at by default. From 3cbd9d00dffcf8ae705821d539f66d1ddab7900b Mon Sep 17 00:00:00 2001 From: eniad Date: Sat, 18 Nov 2023 20:51:06 -0500 Subject: [PATCH 2/4] update readme with correct default port and docker image link why can't I ever catch these things before I submit a PR? --- website/docs/applications/media-serving/kavita.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/docs/applications/media-serving/kavita.md b/website/docs/applications/media-serving/kavita.md index d1ab43f472..e15c837637 100644 --- a/website/docs/applications/media-serving/kavita.md +++ b/website/docs/applications/media-serving/kavita.md @@ -6,7 +6,7 @@ Homepage: Github: -Docker Image: +Docker Image: Lighting fast with a slick design, Kavita is a rocket fueled self-hosted digital library which supports a vast array of file formats. Install to start reading and share your server with your friends. @@ -14,4 +14,4 @@ Lighting fast with a slick design, Kavita is a rocket fueled self-hosted digital Set `kavita_enabled: true` in your `inventories//nas.yml` file. -Access the webui at by default. +Access the webui at by default. From 287487b45cf16c37550814bfd6f3f3e93efded8c Mon Sep 17 00:00:00 2001 From: eniad Date: Sun, 19 Nov 2023 14:46:30 -0500 Subject: [PATCH 3/4] fix in-container port for traefik --- roles/kavita/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/kavita/tasks/main.yml b/roles/kavita/tasks/main.yml index 7f1cc58c2d..8eaa20b288 100644 --- a/roles/kavita/tasks/main.yml +++ b/roles/kavita/tasks/main.yml @@ -31,7 +31,7 @@ traefik.http.routers.kavita.tls.certresolver: "letsencrypt" traefik.http.routers.kavita.tls.domains[0].main: "{{ ansible_nas_domain }}" traefik.http.routers.kavita.tls.domains[0].sans: "*.{{ ansible_nas_domain }}" - traefik.http.services.kavita.loadbalancer.server.port: "5002" + traefik.http.services.kavita.loadbalancer.server.port: "5000" when: kavita_enabled is true - name: Stop Kavita From 30f9d2f9479b6621eb51d3480a5651dca1367640 Mon Sep 17 00:00:00 2001 From: eniad Date: Wed, 6 Dec 2023 07:47:07 -0500 Subject: [PATCH 4/4] correct internal config directory path --- roles/kavita/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/kavita/tasks/main.yml b/roles/kavita/tasks/main.yml index 8eaa20b288..34b2638478 100644 --- a/roles/kavita/tasks/main.yml +++ b/roles/kavita/tasks/main.yml @@ -14,7 +14,7 @@ image: "{{ kavita_image }}" pull: true volumes: - - "{{ kavita_data_directory }}/config:/kavita/config" + - "{{ kavita_data_directory }}/config:/config" - "{{ kavita_comics_directory }}:/comics" - "{{ kavita_books_directory }}:/books" env: