bundlewrap/bundles/openvpn-client/items.py

25 lines
673 B
Python
Raw Normal View History

2020-11-13 21:15:36 +00:00
from os.path import join
directories = {
'/etc/openvpn/client': {
2022-11-21 18:31:49 +00:00
'mode': '0750',
'owner': 'openvpn',
'purge': True,
2020-11-13 21:15:36 +00:00
},
}
2022-11-21 18:31:49 +00:00
for fname, config in node.metadata.get('openvpn-client/configs', {}).items():
files[f'/etc/openvpn/client/{fname}.conf'] = {
'content': repo.vault.decrypt_file(join('openvpn-client', f'{fname}.conf.vault')),
2020-11-13 21:15:36 +00:00
'triggers': {
f'svc_systemd:openvpn-client@{config}:restart',
2022-11-21 18:31:49 +00:00
} if config.get('running', True) else set(),
2020-11-13 21:15:36 +00:00
}
2022-11-21 18:31:49 +00:00
svc_systemd[f'openvpn-client@{fname}'] = {
2020-11-13 21:15:36 +00:00
'needs': {
2022-11-21 18:31:49 +00:00
f'file:/etc/openvpn/client/{fname}.conf',
2020-11-13 21:15:36 +00:00
},
2022-11-21 18:31:49 +00:00
**config,
2020-11-13 21:15:36 +00:00
}