From a2c680f3e8dd11a4500c47d7a83be97e532856ec Mon Sep 17 00:00:00 2001 From: Tobias Reisinger Date: Wed, 30 Oct 2024 03:52:16 +0100 Subject: [PATCH] Add remote docker volumes (using rclone) --- .../filter_plugins/map_backup_locations.py | 3 ++ playbooks/roles/immich/vars/main.yml | 2 +- playbooks/roles/jellyfin/vars/main.yml | 2 +- .../software/tasks/docker-rclone-plugin.yml | 29 +++++++++++++++++++ playbooks/roles/software/tasks/main.yml | 2 ++ services.auto.tfvars | 6 ++-- 6 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 playbooks/roles/software/tasks/docker-rclone-plugin.yml diff --git a/playbooks/filter_plugins/map_backup_locations.py b/playbooks/filter_plugins/map_backup_locations.py index 5f35a15..c4df311 100644 --- a/playbooks/filter_plugins/map_backup_locations.py +++ b/playbooks/filter_plugins/map_backup_locations.py @@ -22,6 +22,9 @@ class FilterModule(object): if location["type"] == "docker": new_location["from"] = name new_location["type"] = "volume" + if location["type"] == "docker_remote": + new_location["from"] = name + new_location["type"] = "volume" if location["type"] == "hook": backup_dir = f"/opt/services/_backup/{name}" diff --git a/playbooks/roles/immich/vars/main.yml b/playbooks/roles/immich/vars/main.yml index c967f7b..1d440e0 100644 --- a/playbooks/roles/immich/vars/main.yml +++ b/playbooks/roles/immich/vars/main.yml @@ -68,6 +68,6 @@ immich_compose: default: volumes: - upload: + upload: "{{ vault_immich.upload_volume_driver }}" pgdata: model-cache: diff --git a/playbooks/roles/jellyfin/vars/main.yml b/playbooks/roles/jellyfin/vars/main.yml index 91472aa..9781164 100644 --- a/playbooks/roles/jellyfin/vars/main.yml +++ b/playbooks/roles/jellyfin/vars/main.yml @@ -23,4 +23,4 @@ jellyfin_compose: volumes: config: cache: - media: + media: "{{ vault_jellyfin.media_volume_driver }}" diff --git a/playbooks/roles/software/tasks/docker-rclone-plugin.yml b/playbooks/roles/software/tasks/docker-rclone-plugin.yml new file mode 100644 index 0000000..488cfc2 --- /dev/null +++ b/playbooks/roles/software/tasks/docker-rclone-plugin.yml @@ -0,0 +1,29 @@ +- name: Install fuse system packages + ansible.builtin.apt: + pkg: + - fuse + state: present + update_cache: true + become: true + +- name: Create the rclone plugin config dir + ansible.builtin.file: + path: "/var/lib/docker-plugins/rclone/config" + state: directory + mode: "0755" + become: true + +- name: Create the rclone plugin cache dir + ansible.builtin.file: + path: "/var/lib/docker-plugins/rclone/cache" + state: directory + mode: "0755" + become: true + +- name: Install rclone plugin + community.docker.docker_plugin: + alias: rclone + plugin_name: rclone/docker-volume-rclone:amd64 + plugin_options: + args: "-v" + state: enable diff --git a/playbooks/roles/software/tasks/main.yml b/playbooks/roles/software/tasks/main.yml index a8db4c9..31dd691 100644 --- a/playbooks/roles/software/tasks/main.yml +++ b/playbooks/roles/software/tasks/main.yml @@ -7,6 +7,8 @@ - name: Install docker ansible.builtin.import_tasks: docker.yml +- name: Install docker rclone plugin + ansible.builtin.import_tasks: docker-rclone-plugin.yml - name: Install jq and bzip2 ansible.builtin.apt: diff --git a/services.auto.tfvars b/services.auto.tfvars index 4f07a6f..6f57077 100644 --- a/services.auto.tfvars +++ b/services.auto.tfvars @@ -184,7 +184,7 @@ services = { backup = [ { name = "immich_upload" - type = "docker" + type = "docker_remote" }, { name = "immich_database" @@ -223,7 +223,7 @@ services = { }, "jellyfin" = { - host = "node002" + host = "node001" dns = [{ domain = "media.serguzim.me" }] @@ -234,7 +234,7 @@ services = { }, { name = "jellyfin_media" - type = "docker" + type = "docker_remote" } ] monitoring = {