aboutsummaryrefslogtreecommitdiffstats
path: root/molecule/default
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 /molecule/default
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 'molecule/default')
-rw-r--r--molecule/default/converge.yml2
-rw-r--r--molecule/default/tests/test_server_setup.py33
2 files changed, 35 insertions, 0 deletions
diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml
index fec5f95..be65609 100644
--- a/molecule/default/converge.yml
+++ b/molecule/default/converge.yml
@@ -146,6 +146,7 @@
borg_ssh_key_per_repo: true
borg_ssh_key_type: ed25519
borg_mode_append_only: true
+ borg_storage_quota: 10G
borg_compression: zstd
borg_included_dirs:
- /etc
@@ -159,6 +160,7 @@
borg_ssh_key_per_repo: true
borg_ssh_key_type: ed25519
borg_mode_append_only: false
+ borg_storage_quota: 50G
borg_compression: lz4
borg_included_dirs:
- /home
diff --git a/molecule/default/tests/test_server_setup.py b/molecule/default/tests/test_server_setup.py
index 5ec1520..0a987b2 100644
--- a/molecule/default/tests/test_server_setup.py
+++ b/molecule/default/tests/test_server_setup.py
@@ -120,6 +120,39 @@ class TestBorgSSHSetup:
'borg-client-multi should NOT have access to borg-client-2 repo'
)
+ def test_authorized_keys_has_storage_quota(self, host):
+ """Verify storage quota is set in authorized_keys for configured repos"""
+ auth_keys = host.file('/opt/borg/.ssh/authorized_keys')
+ content = auth_keys.content_string
+
+ quotas = re.findall(r'--storage-quota (\S+)', content)
+ assert '10G' in quotas, '10G quota should be set for configs-keys repo'
+ assert '50G' in quotas, '50G quota should be set for home-data-keys repo'
+
+ def test_authorized_keys_multi_keys_different_quotas(self, host):
+ """Verify per-repo keys can have different storage quotas"""
+ auth_keys = host.file('/opt/borg/.ssh/authorized_keys')
+ content = auth_keys.content_string
+
+ multi_keys_lines = [
+ line for line in content.split('\n')
+ if line and 'root@borg-client-multi-keys' in line
+ ]
+
+ assert len(multi_keys_lines) == 2, (
+ f"Should have two entries for borg-client-multi-keys, found {len(multi_keys_lines)}"
+ )
+
+ configs_line = [l for l in multi_keys_lines if 'configs-keys' in l][0]
+ home_data_line = [l for l in multi_keys_lines if 'home-data-keys' in l][0]
+
+ assert '--storage-quota 10G' in configs_line, (
+ 'configs-keys should have 10G quota'
+ )
+ assert '--storage-quota 50G' in home_data_line, (
+ 'home-data-keys should have 50G quota'
+ )
+
class TestBorgRepository:
def test_repo_directory_exists(self, host):