bundlewrap/bundles/openvpn-client/items.py

26 lines
696 B
Python
Raw Permalink 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',
'group': None,
'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
}