From ca070782c9663020b5e9c152f0e6b37a58e05482 Mon Sep 17 00:00:00 2001 From: Ivan Reshetnikov Date: Tue, 19 Nov 2024 17:26:34 +0500 Subject: [PATCH] Make archivebox role customizable External HDD is no longer needed. UID, GID and container tag may be changed. The time zone now matches the host. --- archivebox.yml | 1 + roles/archivebox/meta/argument_specs.yml | 11 +++++++++++ roles/archivebox/tasks/main.yml | 17 +++++++++-------- roles/archivebox/vars/main.yml | 6 ++++++ 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/archivebox.yml b/archivebox.yml index 4a4f8d0..8fe4153 100644 --- a/archivebox.yml +++ b/archivebox.yml @@ -4,3 +4,4 @@ - name: archivebox csrf_trusted_origins: https://archive.comfycamp.space allowed_hosts: archive.comfycamp.space + archive_dir: /mnt/hdd/archivebox-data diff --git a/roles/archivebox/meta/argument_specs.yml b/roles/archivebox/meta/argument_specs.yml index 9a9370d..b71853e 100644 --- a/roles/archivebox/meta/argument_specs.yml +++ b/roles/archivebox/meta/argument_specs.yml @@ -2,12 +2,23 @@ argument_specs: main: options: + tag: + type: str + uid: + type: int + gid: + type: int + archive_dir: + type: str + description: "Path to the archive directory" csrf_trusted_origins: type: str required: true + description: "Full URL to your instance, e.g. https://example.com" allowed_hosts: type: str required: true + description: "The domain of your instance, e.g. example.com" public_index: type: bool public_snapshots: diff --git a/roles/archivebox/tasks/main.yml b/roles/archivebox/tasks/main.yml index 0508c41..1470801 100644 --- a/roles/archivebox/tasks/main.yml +++ b/roles/archivebox/tasks/main.yml @@ -6,33 +6,34 @@ - name: Create data dir become: true ansible.builtin.file: - path: /mnt/hdd/archivebox-data + path: "{{ archive_dir }}" state: directory mode: "1700" owner: root - name: Create nested data dir become: true ansible.builtin.file: - path: /mnt/hdd/archivebox-data/_data + path: "{{ archive_dir }}/_data" state: directory mode: "1700" - owner: "911" + owner: "{{ uid | string }}" - name: Run archivebox become: true community.docker.docker_container: name: archivebox-1 - image: archivebox/archivebox:0.7.2 + image: archivebox/archivebox:{{ tag }} 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" + PUID: "{{ uid | string }}" + PGID: "{{ gid | string }}" networks: - name: haproxy volumes: - - archivebox:/data - - /mnt/hdd/archivebox-data/_data:/data/archive + - "archivebox:/data" + - "{{ archive_dir }}/_data:/data/archive" + - "/etc/timezone:/etc/timezone:ro" restart_policy: unless-stopped diff --git a/roles/archivebox/vars/main.yml b/roles/archivebox/vars/main.yml index 897a8da..2f74c9e 100644 --- a/roles/archivebox/vars/main.yml +++ b/roles/archivebox/vars/main.yml @@ -1,3 +1,9 @@ +uid: 911 +gid: 911 +tag: "0.7.2" + public_index: false public_snapshots: false save_archive_dot_org: false + +archive_dir: /var/lib/docker/volumes/archivebox/_data/archive