diff options
| author | Ahmed Abdelhalim <[email protected]> | 2026-06-22 16:55:49 +0200 |
|---|---|---|
| committer | Ahmed Abdelhalim <[email protected]> | 2026-06-22 16:55:49 +0200 |
| commit | ded892e34378c3675717384decebbf87e3f70039 (patch) | |
| tree | 79d6b85a1c592c0ba5ae9245edb5610c3b78ff66 /roles/garage/templates | |
| parent | c8a1d4eac9e5ade57b6bf34dfc26e5516cb43726 (diff) | |
Add garage to rpi to use as s3-compatible backend for backups
Diffstat (limited to 'roles/garage/templates')
| -rw-r--r-- | roles/garage/templates/garage-provision.sh.j2 | 20 | ||||
| -rw-r--r-- | roles/garage/templates/garage.service.j2 | 15 | ||||
| -rw-r--r-- | roles/garage/templates/garage.toml.j2 | 15 |
3 files changed, 50 insertions, 0 deletions
diff --git a/roles/garage/templates/garage-provision.sh.j2 b/roles/garage/templates/garage-provision.sh.j2 new file mode 100644 index 00000000..0402c926 --- /dev/null +++ b/roles/garage/templates/garage-provision.sh.j2 @@ -0,0 +1,20 @@ +#!/bin/bash +set -e + +GARAGE="garage -c /etc/garage/garage.toml" + +if ! $GARAGE layout show 2>/dev/null | grep -q "Current cluster layout"; then + NODE_ID=$($GARAGE node id -q | cut -d@ -f1) + $GARAGE layout assign --zone dc1 --capacity {{ garage_capacity }} "$NODE_ID" + $GARAGE layout apply --version 1 +fi + +if ! $GARAGE bucket list | grep -q "{{ garage_bucket }}"; then + $GARAGE bucket create {{ garage_bucket }} +fi + +if ! $GARAGE key list | grep -q "restic"; then + $GARAGE key import --yes -n restic {{ garage_access_key_id }} {{ garage_secret_access_key }} +fi + +$GARAGE bucket allow --read --write --owner --key {{ garage_access_key_id }} {{ garage_bucket }} diff --git a/roles/garage/templates/garage.service.j2 b/roles/garage/templates/garage.service.j2 new file mode 100644 index 00000000..994f6ac9 --- /dev/null +++ b/roles/garage/templates/garage.service.j2 @@ -0,0 +1,15 @@ +[Unit] +Description=Garage S3-compatible object store +After=network.target + +[Service] +Type=simple +ExecStart=/usr/local/bin/garage -c /etc/garage/garage.toml server +User=garage +Group=garage +Restart=on-failure +StandardOutput=journal +StandardError=journal + +[Install] +WantedBy=multi-user.target diff --git a/roles/garage/templates/garage.toml.j2 b/roles/garage/templates/garage.toml.j2 new file mode 100644 index 00000000..ab6d51a3 --- /dev/null +++ b/roles/garage/templates/garage.toml.j2 @@ -0,0 +1,15 @@ +metadata_dir = "{{ garage_meta_dir }}" +data_dir = "{{ garage_data_dir }}" +db_engine = "sqlite" + +replication_factor = 1 + +rpc_bind_addr = "{{ garage_rpc_bind_addr }}" +rpc_secret = "{{ garage_rpc_secret }}" + +[s3_api] +s3_region = "garage" +api_bind_addr = "0.0.0.0:{{ garage_s3_port }}" + +[admin] +api_bind_addr = "127.0.0.1:{{ garage_admin_port }}" |
