From 787967625076ba0c5059536fd942e7fa5b923dbc Mon Sep 17 00:00:00 2001 From: Ivan Reshetnikov Date: Sat, 2 Nov 2024 19:04:43 +0500 Subject: [PATCH] Run archivebox --- archivebox.yml | 6 ++++ roles/archivebox/meta/argument_specs.yml | 16 ++++++++++ roles/archivebox/tasks/main.yml | 38 ++++++++++++++++++++++++ roles/archivebox/vars/main.yml | 3 ++ roles/haproxy/files/haproxy.cfg | 6 ++++ 5 files changed, 69 insertions(+) create mode 100644 archivebox.yml create mode 100644 roles/archivebox/meta/argument_specs.yml create mode 100644 roles/archivebox/tasks/main.yml create mode 100644 roles/archivebox/vars/main.yml diff --git a/archivebox.yml b/archivebox.yml new file mode 100644 index 0000000..4a4f8d0 --- /dev/null +++ b/archivebox.yml @@ -0,0 +1,6 @@ +--- +- hosts: webservers + roles: + - name: archivebox + csrf_trusted_origins: https://archive.comfycamp.space + allowed_hosts: archive.comfycamp.space diff --git a/roles/archivebox/meta/argument_specs.yml b/roles/archivebox/meta/argument_specs.yml new file mode 100644 index 0000000..9a9370d --- /dev/null +++ b/roles/archivebox/meta/argument_specs.yml @@ -0,0 +1,16 @@ +--- +argument_specs: + main: + options: + csrf_trusted_origins: + type: str + required: true + allowed_hosts: + type: str + required: true + public_index: + type: bool + public_snapshots: + type: bool + save_archive_dot_org: + type: bool diff --git a/roles/archivebox/tasks/main.yml b/roles/archivebox/tasks/main.yml new file mode 100644 index 0000000..0508c41 --- /dev/null +++ b/roles/archivebox/tasks/main.yml @@ -0,0 +1,38 @@ +--- +- name: Create archivebox volume + become: true + community.docker.docker_volume: + name: archivebox +- name: Create data dir + become: true + ansible.builtin.file: + path: /mnt/hdd/archivebox-data + state: directory + mode: "1700" + owner: root +- name: Create nested data dir + become: true + ansible.builtin.file: + path: /mnt/hdd/archivebox-data/_data + state: directory + mode: "1700" + owner: "911" +- name: Run archivebox + become: true + community.docker.docker_container: + name: archivebox-1 + image: archivebox/archivebox:0.7.2 + env: + PUBLIC_INDEX: "{{ public_index | string }}" + PUBLIC_SNAPSHOTS: "{{ public_snapshots | string }}" + SAVE_ARCHIVE_DOT_ORG: "{{ save_archive_dot_org | string }}" + CSRF_TRUSTED_ORIGINS: "{{ csrf_trusted_origins }}" + ALLOWED_HOSTS: "{{ allowed_hosts }}" + PUID: "911" + PGID: "911" + networks: + - name: haproxy + volumes: + - archivebox:/data + - /mnt/hdd/archivebox-data/_data:/data/archive + restart_policy: unless-stopped diff --git a/roles/archivebox/vars/main.yml b/roles/archivebox/vars/main.yml new file mode 100644 index 0000000..897a8da --- /dev/null +++ b/roles/archivebox/vars/main.yml @@ -0,0 +1,3 @@ +public_index: false +public_snapshots: false +save_archive_dot_org: false diff --git a/roles/haproxy/files/haproxy.cfg b/roles/haproxy/files/haproxy.cfg index 7d26b11..2e34cde 100644 --- a/roles/haproxy/files/haproxy.cfg +++ b/roles/haproxy/files/haproxy.cfg @@ -105,6 +105,9 @@ frontend https acl host_grafana hdr(host) -i grafana.comfycamp.space use_backend grafana if host_grafana + acl host_archivebox hdr(host) -i archive.comfycamp.space + use_backend archivebox if host_archivebox + acl host_mta_sts hdr(host) -i mta-sts.comfycamp.space use_backend mta_sts if host_mta_sts @@ -214,3 +217,6 @@ backend immich option http-server-close timeout tunnel 1h server s1 immich-1:2283 check + +backend archivebox + server s1 archivebox-1:8000 check