add bundle:systemd-timers
This commit is contained in:
parent
2a3a26c333
commit
0599c4dae0
7 changed files with 145 additions and 0 deletions
61
bundles/systemd-timers/items.py
Normal file
61
bundles/systemd-timers/items.py
Normal file
|
@ -0,0 +1,61 @@
|
|||
directories = {
|
||||
'/usr/local/lib/systemd/system': {
|
||||
'purge': True,
|
||||
'triggers': {
|
||||
'action:systemd-reload',
|
||||
},
|
||||
},
|
||||
'/var/lib/systemd-timer-monitored': {
|
||||
'mode': '0777',
|
||||
},
|
||||
}
|
||||
|
||||
files = {
|
||||
'/usr/local/sbin/systemd-timer-monitored': {
|
||||
'mode': '0755',
|
||||
},
|
||||
'/usr/local/share/icinga/plugins/check_systemd_timer': {
|
||||
'mode': '0755',
|
||||
},
|
||||
}
|
||||
|
||||
for timer, config in node.metadata.get('systemd-timers/timers', {}).items():
|
||||
if config.get('delete', False):
|
||||
action[f'systemd-timer_stop_timer_{timer}'] = {
|
||||
# can't use svc_systemd: here, because that depends on
|
||||
# action:systemd-reload
|
||||
'command': f'systemctl disable --now {timer}.timer',
|
||||
'precedes': {
|
||||
# stop, then delete unit files
|
||||
'directory:/usr/local/lib/systemd/system',
|
||||
},
|
||||
}
|
||||
else:
|
||||
files[f'/usr/local/lib/systemd/system/{timer}.timer'] = {
|
||||
'source': 'template.timer',
|
||||
'content_type': 'mako',
|
||||
'context': {
|
||||
'timer': timer,
|
||||
'config': config,
|
||||
},
|
||||
'triggers': {
|
||||
'action:systemd-reload',
|
||||
},
|
||||
}
|
||||
files[f'/usr/local/lib/systemd/system/{timer}.service'] = {
|
||||
'source': 'template.service',
|
||||
'content_type': 'mako',
|
||||
'context': {
|
||||
'timer': timer,
|
||||
'config': config,
|
||||
},
|
||||
'triggers': {
|
||||
'action:systemd-reload',
|
||||
},
|
||||
}
|
||||
svc_systemd[f'{timer}.timer'] = {
|
||||
'needs': {
|
||||
f'file:/usr/local/lib/systemd/system/{timer}.service',
|
||||
f'file:/usr/local/lib/systemd/system/{timer}.timer',
|
||||
},
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue