2020-10-18 13:33:41 +00:00
|
|
|
defaults = {
|
2021-05-13 07:10:33 +00:00
|
|
|
'apt': {
|
2022-01-23 04:47:42 +00:00
|
|
|
'unattended-upgrades': {
|
2021-05-13 07:10:33 +00:00
|
|
|
'day': 5,
|
|
|
|
'hour': 21,
|
|
|
|
},
|
|
|
|
},
|
2020-11-10 08:50:20 +00:00
|
|
|
'icinga2_api': {
|
|
|
|
'apt': {
|
|
|
|
'services': {
|
|
|
|
'UNATTENDED UPGRADES': {
|
|
|
|
'command_on_monitored_host': '/usr/local/share/icinga/plugins/check_unattended_upgrades',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-10-18 13:33:41 +00:00
|
|
|
}
|
2020-11-14 11:24:55 +00:00
|
|
|
|
|
|
|
|
2021-01-07 17:44:38 +00:00
|
|
|
@metadata_reactor.provides(
|
2022-02-05 10:41:41 +00:00
|
|
|
'cron/jobs/upgrade-and-reboot'
|
2021-01-07 17:44:38 +00:00
|
|
|
)
|
2020-11-14 11:24:55 +00:00
|
|
|
def patchday(metadata):
|
2024-07-31 12:53:22 +00:00
|
|
|
if not node.metadata.get('apt/unattended-upgrades/enabled', True):
|
|
|
|
return {}
|
|
|
|
|
2022-01-23 04:47:42 +00:00
|
|
|
day = metadata.get('apt/unattended-upgrades/day')
|
|
|
|
hour = metadata.get('apt/unattended-upgrades/hour')
|
2020-11-14 11:24:55 +00:00
|
|
|
|
2023-05-20 05:46:23 +00:00
|
|
|
spread = metadata.get('apt/unattended-upgrades/spread_in_group', None)
|
|
|
|
if spread is not None:
|
|
|
|
spread_nodes = sorted(repo.nodes_in_group(spread))
|
|
|
|
day += spread_nodes.index(node)
|
|
|
|
|
2020-11-14 11:24:55 +00:00
|
|
|
return {
|
|
|
|
'cron': {
|
2022-02-05 10:41:41 +00:00
|
|
|
'jobs': {
|
|
|
|
'upgrade-and-reboot': '{minute} {hour} * * {day} root /usr/local/sbin/upgrade-and-reboot'.format(
|
|
|
|
minute=node.magic_number % 30,
|
|
|
|
hour=hour,
|
2023-05-20 05:46:23 +00:00
|
|
|
day=day%7,
|
2022-02-05 10:41:41 +00:00
|
|
|
),
|
|
|
|
},
|
2020-11-14 11:24:55 +00:00
|
|
|
},
|
|
|
|
}
|