diff --git a/README.md b/README.md index 38a939a2..eae1ddaf 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ If you have a spare domain name you can configure applications to be accessible * [Bitwarden_rs](https://github.com/dani-garcia/bitwarden_rs) - Self-Hosting port of password manager * [Booksonic](https://booksonic.org/) - The selfhosted audiobook server * [Calibre-web](https://github.com/janeczku/calibre-web) - Provides a clean interface for browsing, reading and downloading eBooks using an existing Calibre database. +* [Calibre](https://calibre-ebook.com) - Calibre is a powerful and easy to use e-book manager. * [Code Server](https://code.visualstudio.com/) - Powerful IDE from Microsoft accessible through the browser * [Cloud Commander](https://cloudcmd.io/) - A dual panel file manager with integrated web console and text editor * [Cloudflare DDNS](https://hub.docker.com/r/joshuaavalon/cloudflare-ddns/) - automatically update Cloudflare with your IP address diff --git a/nas.yml b/nas.yml index da82bc9a..9166cb12 100644 --- a/nas.yml +++ b/nas.yml @@ -61,6 +61,11 @@ tags: - calibre + - role: calibremanager + tags: + - calibremanager + when: (calibremanager_enabled | default(False)) + - role: cloudcmd tags: - cloudcmd diff --git a/roles/calibre/tasks/main.yml b/roles/calibre/tasks/main.yml index 0a98a5c4..b6c02e77 100644 --- a/roles/calibre/tasks/main.yml +++ b/roles/calibre/tasks/main.yml @@ -16,6 +16,7 @@ volumes: - "{{ calibre_data_directory }}/config:/config" - "{{ calibre_books_root }}:/books" + - "{{ calibre_data_directory }}/data:/data" env: TZ: "{{ ansible_nas_timezone }}" PUID: "{{ calibre_user_id }}" diff --git a/roles/calibremanager/defaults/main.yml b/roles/calibremanager/defaults/main.yml new file mode 100644 index 00000000..f6cbc88b --- /dev/null +++ b/roles/calibremanager/defaults/main.yml @@ -0,0 +1,28 @@ +--- +calibremanager_enabled: false +calibremanager_available_externally: "false" + +# uid / gid +calibremanager_user_id: "1000" +calibremanager_group_id: "1000" + +# directories +calibremanager_data_directory: "{{ docker_home }}/calibremanager" +calibremanager_books_directory: "{{ books_root }}" +calibremanager_comics_directory: "{{ comics_root }}" + +# network +calibremanager_port: "8093" +calibremanager_webserver_port: "8094" +calibremanager_hostname: "calibremanager" + +# env +calibremanager_password: "" +calibremanager_cli_args: "" +calibremanager_security_opts: "seccomp=unconfined" # For why this is here, see https://github.com/linuxserver/docker-calibre/issues/102 + +# specs +calibremanager_memory: 1g + +# docker +calibremanager_container_name: calibremanager diff --git a/roles/calibremanager/molecule/default/molecule.yml b/roles/calibremanager/molecule/default/molecule.yml new file mode 100644 index 00000000..9f13c255 --- /dev/null +++ b/roles/calibremanager/molecule/default/molecule.yml @@ -0,0 +1,6 @@ +--- +provisioner: + inventory: + group_vars: + all: + calibremanager_enabled: true diff --git a/roles/calibremanager/molecule/default/side_effect.yml b/roles/calibremanager/molecule/default/side_effect.yml new file mode 100644 index 00000000..1fa2b2a6 --- /dev/null +++ b/roles/calibremanager/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: + calibremanager_enabled: false diff --git a/roles/calibremanager/molecule/default/verify.yml b/roles/calibremanager/molecule/default/verify.yml new file mode 100644 index 00000000..7e1a983c --- /dev/null +++ b/roles/calibremanager/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: "{{ calibremanager_container_name }}" + register: result + + - name: Check Calibre is running + assert: + that: + - result.container['State']['Status'] == "running" + - result.container['State']['Restarting'] == false diff --git a/roles/calibremanager/molecule/default/verify_stopped.yml b/roles/calibremanager/molecule/default/verify_stopped.yml new file mode 100644 index 00000000..86bdf083 --- /dev/null +++ b/roles/calibremanager/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 Calibre + docker_container: + name: "{{ calibremanager_container_name }}" + state: absent + register: result + + - name: Check Calibre is stopped + assert: + that: + - not result.changed diff --git a/roles/calibremanager/tasks/main.yml b/roles/calibremanager/tasks/main.yml new file mode 100644 index 00000000..447b0928 --- /dev/null +++ b/roles/calibremanager/tasks/main.yml @@ -0,0 +1,45 @@ +--- +- name: Create Calibre Directories + file: + path: "{{ item }}" + state: directory + mode: 0755 + with_items: + - "{{ calibremanager_data_directory }}/data" + +- name: Calibre Docker Container + docker_container: + name: "{{ calibremanager_container_name }}" + image: linuxserver/calibre + pull: true + volumes: + - "{{ calibremanager_data_directory }}/data:/config:rw" + - "{{ calibremanager_books_directory }}:/books:rw" + - "{{ calibremanager_comics_directory }}:/comics:rw" + ports: + - "{{ calibremanager_port }}:8080" + - "{{ calibremanager_webserver_port }}:8081" + security_opts: "{{ calibremanager_security_opts }}" + env: + TZ: "{{ ansible_nas_timezone }}" + PUID: "{{ calibremanager_user_id }}" + PGID: "{{ calibremanager_group_id }}" + PASSWORD: "{{ calibremanager_password }}" + CLI_ARGS: "{{ calibremanager_cli_args }}" + restart_policy: unless-stopped + memory: "{{ calibremanager_memory }}" + labels: + traefik.enable: "{{ calibremanager_available_externally }}" + traefik.http.routers.calibre.rule: "Host(`{{ calibremanager_hostname }}.{{ ansible_nas_domain }}`)" + traefik.http.routers.calibre.tls.certresolver: "letsencrypt" + traefik.http.routers.calibre.tls.domains[0].main: "{{ ansible_nas_domain }}" + traefik.http.routers.calibre.tls.domains[0].sans: "*.{{ ansible_nas_domain }}" + traefik.http.services.calibre.loadbalancer.server.port: "8080" + +- name: Stop Calibre Manager + block: + - name: Stop Calibre Manager + docker_container: + name: "{{ calibremanager_container_name }}" + state: absent + when: calibremanager_enabled is false \ No newline at end of file diff --git a/website/docs/applications/media-serving/calibremanager.md b/website/docs/applications/media-serving/calibremanager.md new file mode 100644 index 00000000..cb462b5d --- /dev/null +++ b/website/docs/applications/media-serving/calibremanager.md @@ -0,0 +1,34 @@ +# Calibre + +Homepage: [https://calibre-ebook.com](https://calibre-ebook.com) + +Calibre is a powerful and easy to use e-book manager. + +## Usage + +Set `calibremanager_enabled: true` in your `inventories//nas.yml` file. + +## Specific Configuration + +By default, there is no password set for the main gui. Optional `calibremanager_password` will allow setting a password for the user `abc`. + +Optionally, cli start arguments can be passed to calibre using `calibremanager_cli_args`. + +The Calibre webserver must be turned on in the Calibre manager to make it available at the selected port (8094 by default). + +## Use with Calibre-web + +Ansible-NAS has long come with [../calibre](Calibre-web). To allow Calibre-web direct access to the Calibre database, both applications can share a Docker data directory. To do so, include the following in your inventory `nas.yml`: + +```yml +calibremanager_data_directory: "{{ docker_home }}/calibre" +``` + +In this case, the Calibre Database Directory is `/data/Calibre Library` + +## Ports + +```yml +calibremanager_port: "8093" +calibremanager_webserver_port: "8094" +```