aboutsummaryrefslogtreecommitdiffstats
path: root/tasks/client_setup.yml
diff options
context:
space:
mode:
Diffstat (limited to 'tasks/client_setup.yml')
-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