From 8b0175c70cbf3ed63c9a0e617c3f1e5332650ff6 Mon Sep 17 00:00:00 2001 From: Colin Wilk Date: Sat, 27 Jun 2026 21:20:35 +0000 Subject: 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. --- tasks/client_setup.yml | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'tasks') 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 -- cgit v1.2.3