bundlewrap/bundles/backup-server/items.py
Franziska Kunsmann b06532241b
All checks were successful
bundlewrap/pipeline/head This commit looks good
bundles: use metastack syntax for metadata.get()
2021-02-18 18:12:25 +01:00

28 lines
725 B
Python

assert node.has_bundle('zfs')
from os.path import join
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': {
'bundle:zfs',
},
}
directories[f'/srv/backups/{nodename}/backups'] = {
'owner': config['user'],
'mode': '0700',
'needs': {
'bundle:zfs',
},
}