From 1bf3fa1e310f600e99603f1b7a49fe8fe4ab4873 Mon Sep 17 00:00:00 2001 From: Anarion Date: Tue, 18 Jun 2024 14:52:49 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20Shiori?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + nas.yml | 4 + roles/shiori/defaults/main.yml | 63 ++++++++++++++++ roles/shiori/docs/shiori.md | 11 +++ roles/shiori/molecule/default/molecule.yml | 6 ++ roles/shiori/molecule/default/side_effect.yml | 10 +++ roles/shiori/molecule/default/verify.yml | 26 +++++++ .../molecule/default/verify_stopped.yml | 26 +++++++ roles/shiori/requirements.yml | 1 + roles/shiori/tasks/main.yml | 75 +++++++++++++++++++ website/docs/applications/other/shiori.md | 14 ++++ 11 files changed, 237 insertions(+) create mode 100644 roles/shiori/defaults/main.yml create mode 100644 roles/shiori/docs/shiori.md create mode 100644 roles/shiori/molecule/default/molecule.yml create mode 100644 roles/shiori/molecule/default/side_effect.yml create mode 100644 roles/shiori/molecule/default/verify.yml create mode 100644 roles/shiori/molecule/default/verify_stopped.yml create mode 120000 roles/shiori/requirements.yml create mode 100644 roles/shiori/tasks/main.yml create mode 100644 website/docs/applications/other/shiori.md diff --git a/README.md b/README.md index 3d31be0a18..14e7dd9550 100644 --- a/README.md +++ b/README.md @@ -207,6 +207,7 @@ If you have a spare domain name you can configure applications to be accessible * [SearxNG](https://github.com/searxng/searxng) - Free internet metasearch engine * [Servas](https://github.com/beromir/Servas) - A self-hosted bookmark management tool * [Shaarli](https://github.com/shaarli/Shaarli) - Personal, minimalist, super-fast, database free, bookmarking service +* [Shiori](https://github.com/go-shiori/shiori) - Simple bookmark manager built with Go * [Sickchill](https://sickchill.github.io/) - for managing TV episodes * [Silverbullet](https://silverbullet.md) - Note-taking application optimized for people with a hacker mindset * [SiYuan](https://github.com/siyuan-note/siyuan) - A privacy-first, self-hosted, fully open source personal knowledge management software diff --git a/nas.yml b/nas.yml index ce54d067ed..71a1b456a9 100644 --- a/nas.yml +++ b/nas.yml @@ -801,6 +801,10 @@ tags: - shaarli + - role: shiori + tags: + - shiori + - role: servas tags: - servas diff --git a/roles/shiori/defaults/main.yml b/roles/shiori/defaults/main.yml new file mode 100644 index 0000000000..9e1453cb2a --- /dev/null +++ b/roles/shiori/defaults/main.yml @@ -0,0 +1,63 @@ +--- +shiori_enabled: false +shiori_available_externally: false + +# directories +shiori_data_directory: "{{ docker_home }}/shiori" + +# network +shiori_port: "8165" +shiori_hostname: "shiori" +shiori_network_name: "shiori" + +# specs +shiori_memory: 1g +shiori_db_memory: 1g + +# docker +shiori_container_name: shiori +shiori_image_name: "ghcr.io/go-shiori/shiori" +shiori_image_version: latest +shiori_db_container_name: shiori-postgres +shiori_db_image_name: postgres +shiori_db_image_version: 15-alpine +shiori_user_id: "1000" +shiori_group_id: "1000" + + +# shiori +shiori_postgres_user: shiori +shiori_postgres_password: shiori +shiori_postgres_db: shiori +shiori_http_enabled: "true" +shiori_http_port: "8080" +shiori_http_address: ":" +shiori_http_root_path: "/" +shiori_http_access_log: "true" +shiori_http_serve_web_ui: "true" +shiori_http_secret_key: "secret_key_to_be_changed" +shiori_http_body_limit: "1024" +shiori_http_read_timeout: "10s" +shiori_http_write_timeout: "10s" +shiori_http_idle_timeout: "10s" +shiori_http_disable_keep_alive: "true" +shiori_http_disable_parse_multipart_form: "true" +shiori_data_directory_env: "/data" +shiori_database_url: "postgres://{{ shiori_postgres_user }}:{{ shiori_postgres_password }}@{{ shiori_db_container_name }}/{{ shiori_postgres_db }}?sslmode=disable" + +shiori_env: + SHIORI_HTTP_ENABLED: "{{ shiori_http_enabled }}" + SHIORI_HTTP_PORT: "{{ shiori_http_port }}" + SHIORI_HTTP_ADDRESS: "{{ shiori_http_address }}" + SHIORI_HTTP_ROOT_PATH: "{{ shiori_http_root_path }}" + SHIORI_HTTP_ACCESS_LOG: "{{ shiori_http_access_log }}" + SHIORI_HTTP_SERVE_WEB_UI: "{{ shiori_http_serve_web_ui }}" + SHIORI_HTTP_SECRET_KEY: "{{ shiori_http_secret_key }}" + SHIORI_HTTP_BODY_LIMIT: "{{ shiori_http_body_limit }}" + SHIORI_HTTP_READ_TIMEOUT: "{{ shiori_http_read_timeout }}" + SHIORI_HTTP_WRITE_TIMEOUT: "{{ shiori_http_write_timeout }}" + SHIORI_HTTP_IDLE_TIMEOUT: "{{ shiori_http_idle_timeout }}" + SHIORI_HTTP_DISABLE_KEEP_ALIVE: "{{ shiori_http_disable_keep_alive }}" + SHIORI_HTTP_DISABLE_PARSE_MULTIPART_FORM: "{{ shiori_http_disable_parse_multipart_form }}" + SHIORI_DIR: "{{ shiori_data_directory_env }}" + SHIORI_DATABASE_URL: "{{ shiori_database_url }}" diff --git a/roles/shiori/docs/shiori.md b/roles/shiori/docs/shiori.md new file mode 100644 index 0000000000..d2c8597117 --- /dev/null +++ b/roles/shiori/docs/shiori.md @@ -0,0 +1,11 @@ +# Shiori + +Homepage: [https://github.com/go-shiori/shiori](https://github.com/go-shiori/shiori) + +Shiori is a simple bookmarks manager written in the Go language. Intended as a simple clone of Pocket. + +## Usage + +Set `shiori_enabled: true` in your `inventories//group_vars/nas.yml` file. + +Shiori web interface can be found at [http://ansible_nas_host_or_ip:8165](http://ansible_nas_host_or_ip:8165). Login with default username `shiori` and default password `gopher`. diff --git a/roles/shiori/molecule/default/molecule.yml b/roles/shiori/molecule/default/molecule.yml new file mode 100644 index 0000000000..42da1a93ea --- /dev/null +++ b/roles/shiori/molecule/default/molecule.yml @@ -0,0 +1,6 @@ +--- +provisioner: + inventory: + group_vars: + all: + shiori_enabled: true diff --git a/roles/shiori/molecule/default/side_effect.yml b/roles/shiori/molecule/default/side_effect.yml new file mode 100644 index 0000000000..5cdec1502b --- /dev/null +++ b/roles/shiori/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" + ansible.builtin.include_role: + name: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }}" + vars: + shiori_enabled: false diff --git a/roles/shiori/molecule/default/verify.yml b/roles/shiori/molecule/default/verify.yml new file mode 100644 index 0000000000..55e012c0cd --- /dev/null +++ b/roles/shiori/molecule/default/verify.yml @@ -0,0 +1,26 @@ +--- +- name: Verify + hosts: all + gather_facts: false + tasks: + - name: Include vars + ansible.builtin.include_vars: + file: ../../defaults/main.yml + + - name: Get shiori db container state + community.docker.docker_container: + name: "{{ shiori_db_container_name }}" + register: result_db + + - name: Get shiori container state + community.docker.docker_container: + name: "{{ shiori_container_name }}" + register: result + + - name: Check if shiori containers are running + ansible.builtin.assert: + that: + - result_db.container['State']['Status'] == "running" + - result_db.container['State']['Restarting'] == false + - result.container['State']['Status'] == "running" + - result.container['State']['Restarting'] == false diff --git a/roles/shiori/molecule/default/verify_stopped.yml b/roles/shiori/molecule/default/verify_stopped.yml new file mode 100644 index 0000000000..1764e883b7 --- /dev/null +++ b/roles/shiori/molecule/default/verify_stopped.yml @@ -0,0 +1,26 @@ +--- +- name: Verify + hosts: all + gather_facts: false + tasks: + - name: Include vars + ansible.builtin.include_vars: + file: ../../defaults/main.yml + + - name: Try and stop and remove shiori db + community.docker.docker_container: + name: "{{ shiori_db_container_name }}" + state: absent + register: result_db + + - name: Try and stop and remove shiori + community.docker.docker_container: + name: "{{ shiori_container_name }}" + state: absent + register: result + + - name: Check if shiori is stopped + ansible.builtin.assert: + that: + - not result_db.changed + - not result.changed diff --git a/roles/shiori/requirements.yml b/roles/shiori/requirements.yml new file mode 120000 index 0000000000..9a736435ab --- /dev/null +++ b/roles/shiori/requirements.yml @@ -0,0 +1 @@ +../../requirements.yml \ No newline at end of file diff --git a/roles/shiori/tasks/main.yml b/roles/shiori/tasks/main.yml new file mode 100644 index 0000000000..c160121e9a --- /dev/null +++ b/roles/shiori/tasks/main.yml @@ -0,0 +1,75 @@ +--- +- name: Start Shiori + block: + - name: Create Shiori Directories + ansible.builtin.file: + path: "{{ item }}" + state: directory + owner: 1001 + group: 65533 + with_items: + - "{{ shiori_data_directory }}" + - "{{ shiori_data_directory }}/uploads" + + - name: Create Shiori network + community.docker.docker_network: + name: "{{ shiori_network_name }}" + + - name: Create Shiori DB Docker Container + community.docker.docker_container: + name: "{{ shiori_db_container_name }}" + image: "{{ shiori_db_image_name }}:{{ shiori_db_image_version }}" + pull: true + volumes: + - "{{ shiori_data_directory }}/postgres:/var/lib/postgresql/data:rw" + networks: + - name: "{{ shiori_network_name }}" + network_mode: "{{ shiori_network_name }}" + container_default_behavior: no_defaults + env: + POSTGRES_PASSWORD: "{{ shiori_postgres_password }}" + POSTGRES_USER: "{{ shiori_postgres_user }}" + POSTGRES_DB: "{{ shiori_postgres_db }}" + labels: + traefik.enable: "false" + restart_policy: always + memory: "{{ shiori_db_memory }}" + + - name: Create Shiori Docker Container + community.docker.docker_container: + container_default_behavior: no_defaults + name: "{{ shiori_container_name }}" + image: "{{ shiori_image_name }}:{{ shiori_image_version }}" + pull: true + volumes: + - "{{ shiori_data_directory }}/dev-data:/srv/shiori" + - "{{ shiori_data_directory }}/data:/data" + networks: + - name: "{{ shiori_network_name }}" + network_mode: "{{ shiori_network_name }}" + ports: + - "{{ shiori_port }}:8080" + env: "{{ shiori_env }}" + restart_policy: unless-stopped + memory: "{{ shiori_memory }}" + labels: + traefik.enable: "{{ shiori_available_externally | string }}" + traefik.http.routers.shiori.rule: "Host(`{{ shiori_hostname }}.{{ ansible_nas_domain }}`)" + traefik.http.routers.shiori.tls.certresolver: "letsencrypt" + traefik.http.routers.shiori.tls.domains[0].main: "{{ ansible_nas_domain }}" + traefik.http.routers.shiori.tls.domains[0].sans: "*.{{ ansible_nas_domain }}" + traefik.http.services.shiori.loadbalancer.server.port: "8080" + when: shiori_enabled is true + +- name: Stop Shiori + block: + - name: Stop Shiori DB + community.docker.docker_container: + name: "{{ shiori_db_container_name }}" + state: absent + + - name: Stop Shiori + community.docker.docker_container: + name: "{{ shiori_container_name }}" + state: absent + when: shiori_enabled is false diff --git a/website/docs/applications/other/shiori.md b/website/docs/applications/other/shiori.md new file mode 100644 index 0000000000..e417a1227e --- /dev/null +++ b/website/docs/applications/other/shiori.md @@ -0,0 +1,14 @@ +--- +title: "Shiori" +description: "Simple bookmark manager built with Go" +--- + +Homepage: [https://github.com/go-shiori/shiori](https://github.com/go-shiori/shiori) + +Shiori is a simple bookmarks manager written in the Go language. Intended as a simple clone of Pocket. + +## Usage + +Set `shiori_enabled: true` in your `inventories//group_vars/nas.yml` file. + +Shiori web interface can be found at [http://ansible_nas_host_or_ip:8165](http://ansible_nas_host_or_ip:8165). Login with default username `shiori` and default password `gopher`.