bundles/apt: support spreading unattended-upgrades in a group
This commit is contained in:
parent
92cca7f396
commit
048fb83ee7
5 changed files with 81 additions and 24 deletions
|
@ -346,7 +346,8 @@ svc_systemd = {
|
|||
|
||||
# The actual hosts and services management starts here
|
||||
bundles = set()
|
||||
for rnode in repo.nodes:
|
||||
downtimes = []
|
||||
for rnode in sorted(repo.nodes):
|
||||
if rnode.metadata.get('icinga_options/exclude_from_monitoring', False):
|
||||
continue
|
||||
|
||||
|
@ -388,6 +389,41 @@ for rnode in repo.nodes:
|
|||
|
||||
bundles |= set(rnode.metadata.get('icinga2_api', {}).keys())
|
||||
|
||||
if rnode.has_any_bundle(['apt', 'c3voc-addons']):
|
||||
day = rnode.metadata.get('apt/unattended-upgrades/day')
|
||||
hour = rnode.metadata.get('apt/unattended-upgrades/hour')
|
||||
minute = rnode.magic_number%30
|
||||
|
||||
spread = rnode.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(rnode)
|
||||
|
||||
downtimes.append({
|
||||
'name': 'unattended-upgrades',
|
||||
'host': rnode.name,
|
||||
'comment': f'Downtime for upgrade-and-reboot of node {rnode.name}',
|
||||
'times': {
|
||||
DAYS_TO_STRING[day%7]: f'{hour}:{minute}-{hour}:{minute+30}',
|
||||
},
|
||||
})
|
||||
elif (
|
||||
rnode.has_bundle('pacman')
|
||||
and rnode.metadata.get('pacman/unattended-upgrades/is_enabled', False)
|
||||
):
|
||||
day = rnode.metadata.get('pacman/unattended-upgrades/day')
|
||||
hour = rnode.metadata.get('pacman/unattended-upgrades/hour')
|
||||
minute = rnode.magic_number%30
|
||||
|
||||
downtimes.append({
|
||||
'name': 'unattended-upgrades',
|
||||
'host': rnode.name,
|
||||
'comment': f'Downtime for upgrade-and-reboot of node {rnode.name}',
|
||||
'times': {
|
||||
DAYS_TO_STRING[day%7]: f'{hour}:{minute}-{hour}:{minute+30}',
|
||||
},
|
||||
})
|
||||
|
||||
files['/etc/icinga2/conf.d/groups.conf'] = {
|
||||
'source': 'icinga2/groups.conf',
|
||||
'content_type': 'mako',
|
||||
|
@ -408,7 +444,7 @@ files['/etc/icinga2/conf.d/downtimes.conf'] = {
|
|||
'source': 'icinga2/downtimes.conf',
|
||||
'content_type': 'mako',
|
||||
'context': {
|
||||
'days': DAYS_TO_STRING,
|
||||
'downtimes': downtimes,
|
||||
},
|
||||
'owner': 'nagios',
|
||||
'group': 'nagios',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue