aboutsummaryrefslogtreecommitdiffstats
path: root/tasks
diff options
context:
space:
mode:
authorColin Wilk <colin@wilk.cx>2026-06-27 21:20:35 +0000
committerColin Wilk <colin@wilk.cx>2026-06-27 21:28:48 +0000
commit8b0175c70cbf3ed63c9a0e617c3f1e5332650ff6 (patch)
tree4bf466fc21c201833d4b1b9612d8b2abeb82649c /tasks
parent8d872069976c5445c4396804ef3a0196f10eb14b (diff)
downloadansible-role-borgbackup-8b0175c70cbf3ed63c9a0e617c3f1e5332650ff6.tar.gz
ansible-role-borgbackup-8b0175c70cbf3ed63c9a0e617c3f1e5332650ff6.zip
feat: add storage quota support
Add borg_storage_quota variable to limit repository storage on the borg server via --storage-quota option in authorized_keys. When not using borg_ssh_key_per_repo, all repos for a host must share the same quota setting (similar to --append-only). Per-repo SSH keys enable independent quotas per repository.
Diffstat (limited to 'tasks')
-rw-r--r--tasks/client_setup.yml22
1 files changed, 21 insertions, 1 deletions
diff --git a/tasks/client_setup.yml b/tasks/client_setup.yml
index 18d5b18..e39826a 100644
--- a/tasks/client_setup.yml
+++ b/tasks/client_setup.yml
@@ -107,6 +107,16 @@
existing_append_only: "{{ existing_line is search('--append-only') }}"
when: existing_line | length > 0
+- name: Detect --storage-quota setting from existing entry
+ ansible.builtin.set_fact:
+ existing_storage_quota: >-
+ {{
+ (existing_line | regex_findall('--storage-quota[= ](\d+[KMGT]?)')
+ | first
+ | default(""))
+ }}
+ when: existing_line | length > 0
+
- name: Fail if --append-only setting differs from existing entry
ansible.builtin.fail:
msg: |
@@ -117,6 +127,16 @@
- existing_line | length > 0
- existing_append_only != borg_mode_append_only
+- name: Fail if --storage-quota setting differs from existing entry
+ ansible.builtin.fail:
+ msg: |
+ Inconsistent --storage-quota setting for host {{ inventory_hostname }}.
+ Existing entry has --storage-quota={{ existing_storage_quota }}, but current invocation uses --storage-quota={{ borg_storage_quota }}.
+ All repositories for a host must have the same --storage-quota setting.
+ when:
+ - existing_line | length > 0
+ - existing_storage_quota != (borg_storage_quota | default(""))
+
- name: Compute all repos for this host
ansible.builtin.set_fact:
all_repos: >-
@@ -131,7 +151,7 @@
path: "{{ borg_server_user_home }}/.ssh/authorized_keys"
search_string: "{{ ssh_key.public_key | trim }}"
line: >-
- restrict,command="borg serve{{ " --append-only" if borg_mode_append_only }}
+ restrict,command="borg serve{{ " --append-only" if borg_mode_append_only }}{{ " --storage-quota " ~ borg_storage_quota if borg_storage_quota }}
{{ all_repos | map('regex_replace', '^', '--restrict-to-repository ') | join(' ') }}"
{{ ssh_key.public_key | trim }} {{ borg_client_user }}@{{ inventory_hostname }}
state: present