bundles/c3voc-addons: support cron definition
All checks were successful
bundlewrap/pipeline/head This commit looks good

This commit is contained in:
Franzi 2021-01-19 13:34:23 +01:00
parent 0893156723
commit 63cdd470cf
Signed by: kunsi
GPG key ID: 12E3D2136B818350
3 changed files with 26 additions and 6 deletions

View file

@ -0,0 +1 @@
../../cron/files/cron_template

View file

@ -62,12 +62,15 @@ files = {
'data': node.metadata.get('apt', {}).get('unattended-upgrades', {}),
}
},
'/etc/cron.d/upgrade-and-reboot': {
'content': '{minute} 1 * * {day} root /usr/local/sbin/upgrade-and-reboot'.format(
minute=node.magic_number % 30,
day=node.metadata.get('apt', {}).get('unattended-upgrades', {}).get('day', 5),
),
},
}
for crontab, content in node.metadata.get('cron', {}).items():
files['/etc/cron.d/{}'.format(crontab)] = {
'source': 'cron_template',
'content_type': 'mako',
'context': {
'cron': content,
}
}
for vhost, config in node.metadata.get('nginx', {}).get('vhosts', {}).items():

View file

@ -18,6 +18,22 @@ defaults = {
}
@metadata_reactor.provides(
'cron/upgrade-and-reboot'
)
def patchday(metadata):
day = metadata.get('apt/unattended_upgrades/day', 5)
return {
'cron': {
'upgrade-and-reboot': '{minute} 1 * * {day} root /usr/local/sbin/upgrade-and-reboot'.format(
minute=node.magic_number % 30,
day=day,
),
},
}
@metadata_reactor.provides(
'icinga2_api/nginx/services',
)