bundlewrap/bundles/backup-server/items.py
Franziska Kunsmann 58d2576ec9
All checks were successful
kunsi/bundlewrap/pipeline/head This commit looks good
bundles/backup-server: fix dependencies
2021-08-01 07:57:48 +02:00

30 lines
840 B
Python

repo.libs.tools.require_bundle(node, 'zfs')
from os.path import join
dataset = node.metadata.get('backup-server/zfs-base')
for nodename, config in node.metadata.get('backup-server/clients', {}).items():
with open(join(repo.path, 'data', 'backup', 'keys', f'{nodename}.pub'), 'r') as f:
pubkey = f.read().strip()
users[config['user']] = {
'home': f'/srv/backups/{nodename}',
}
files[f'/srv/backups/{nodename}/.ssh/authorized_keys'] = {
'content': pubkey,
'owner': config['user'],
'mode': '0400',
'needs': {
f'zfs_dataset:{dataset}/{nodename}',
},
}
directories[f'/srv/backups/{nodename}/backups'] = {
'owner': config['user'],
'mode': '0700',
'needs': {
f'zfs_dataset:{dataset}/{nodename}',
},
}