wip
This commit is contained in:
parent
b8127713d9
commit
275c6eb22b
4 changed files with 55 additions and 0 deletions
21
bundles/systemd-timers/items.py
Normal file
21
bundles/systemd-timers/items.py
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
for name, config in node.metadata.get('systemd-timers').items():
|
||||||
|
files[f'/etc/systemd/system/{name}.timer'] = {
|
||||||
|
'content': repo.libs.systemd.generate_unitfile({
|
||||||
|
'Unit':{
|
||||||
|
'Description': f'{name} timer',
|
||||||
|
},
|
||||||
|
'Timer': {
|
||||||
|
'OnCalendar': config['when'],
|
||||||
|
'Unit': f'{name}.service',
|
||||||
|
},
|
||||||
|
'Install': {
|
||||||
|
'WantedBy': 'multi-user.target',
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
'triggers': [
|
||||||
|
'action:systemd-reload',
|
||||||
|
f'svc_systemd:{name}:restart',
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
svc_systemd[f'{name}.timer'] = {}
|
27
bundles/systemd-timers/metadata.py
Normal file
27
bundles/systemd-timers/metadata.py
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
defaults = {
|
||||||
|
'systemd-timers': {},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@metadata_reactor.provides(
|
||||||
|
'systemd/services',
|
||||||
|
)
|
||||||
|
def services(metadata):
|
||||||
|
return {
|
||||||
|
'systemd': {
|
||||||
|
'services': {
|
||||||
|
name: {
|
||||||
|
'content': {
|
||||||
|
'Unit':{
|
||||||
|
'Description': f'{name} timer service',
|
||||||
|
},
|
||||||
|
'Service': {
|
||||||
|
'ExecStart': config['command'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'enabled': False,
|
||||||
|
'running': False,
|
||||||
|
} for name, config in metadata.get('systemd-timers').items()
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
|
@ -6,5 +6,6 @@
|
||||||
'network',
|
'network',
|
||||||
'systemd',
|
'systemd',
|
||||||
'systemd-networkd',
|
'systemd-networkd',
|
||||||
|
'systemd-timers',
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,12 @@
|
||||||
'zfs',
|
'zfs',
|
||||||
],
|
],
|
||||||
'metadata': {
|
'metadata': {
|
||||||
|
'systemd-timers': {
|
||||||
|
'test1': {
|
||||||
|
'when': 'weekly',
|
||||||
|
'command': '/bin/ls',
|
||||||
|
},
|
||||||
|
},
|
||||||
'nextcloud': {
|
'nextcloud': {
|
||||||
'hostname': 'cloud.sublimity.de',
|
'hostname': 'cloud.sublimity.de',
|
||||||
'version': '21.0.0',
|
'version': '21.0.0',
|
||||||
|
|
Loading…
Reference in a new issue