bundles/apt: fix metadata key mess (unattended-upgrades vs unattended_upgrades)
All checks were successful
kunsi/bundlewrap/pipeline/head This commit looks good

This commit is contained in:
Franzi 2022-01-23 05:47:42 +01:00
parent 07157b6335
commit 0ccb983b28
Signed by: kunsi
GPG key ID: 12E3D2136B818350
13 changed files with 66 additions and 28 deletions

View file

@ -1,3 +1,3 @@
nodename="${node.name}"
reboot_mail_to="${node.metadata.get('apt/unattended-upgrades/reboot_mail_to', '')}"
auto_reboot_enabled="${node.metadata.get('apt/unattended-upgrades/reboot-enabled', True)}"
auto_reboot_enabled="${node.metadata.get('apt/unattended-upgrades/reboot_enabled', True)}"

View file

@ -1,6 +1,6 @@
defaults = {
'apt': {
'unattended_upgrades': {
'unattended-upgrades': {
'day': 5,
'hour': 21,
},
@ -21,8 +21,8 @@ defaults = {
'cron/upgrade-and-reboot'
)
def patchday(metadata):
day = metadata.get('apt/unattended_upgrades/day')
hour = metadata.get('apt/unattended_upgrades/hour')
day = metadata.get('apt/unattended-upgrades/day')
hour = metadata.get('apt/unattended-upgrades/hour')
return {
'cron': {

View file

@ -1,6 +1,6 @@
defaults = {
'apt': {
'unattended_upgrades': {
'unattended-upgrades': {
'day': 5,
'hour': 21,
},
@ -28,8 +28,8 @@ defaults = {
'cron/upgrade-and-reboot'
)
def patchday(metadata):
day = metadata.get('apt/unattended_upgrades/day')
hour = metadata.get('apt/unattended_upgrades/hour')
day = metadata.get('apt/unattended-upgrades/day')
hour = metadata.get('apt/unattended-upgrades/hour')
return {
'cron': {

View file

@ -9,7 +9,7 @@ object ScheduledDowntime "unattended_upgrades" {
fixed = true
ranges = {
"${days[monitored_node.metadata.get('apt/unattended_upgrades/day')]}" = "${monitored_node.metadata.get('apt/unattended_upgrades/hour')}:${monitored_node.magic_number%30}-${monitored_node.metadata.get('apt/unattended_upgrades/hour')}:${(monitored_node.magic_number%30)+30}"
"${days[monitored_node.metadata.get('apt/unattended-upgrades/day')]}" = "${monitored_node.metadata.get('apt/unattended-upgrades/hour')}:${monitored_node.magic_number%30}-${monitored_node.metadata.get('apt/unattended-upgrades/hour')}:${(monitored_node.magic_number%30)+30}"
}
child_options = "DowntimeTriggeredChildren"

View file

@ -110,6 +110,13 @@ groups['voc'] = {
r"voc\..*",
},
'metadata': {
'apt': {
# Move patchday to somewhere where the possibility of
# clashing with actual events is less likely.
'unattended-upgrades': {
'day': 1,
},
},
'location': 'voc',
},
}

View file

@ -34,7 +34,7 @@ groups['linux'] = {
'metadata': {
'apt': {
'unattended-upgrades': {
'mail': libs.defaults.hostmaster_email,
'reboot_mail_to': libs.defaults.hostmaster_email,
},
},
'backup-client': {

View file

@ -0,0 +1,45 @@
from collections.abc import Mapping
from bundlewrap.exceptions import BundleError
from bundlewrap.utils.text import bold, green
from bundlewrap.utils.ui import io
def test_underscore_vs_dash(node, metadata, path=[]):
for k, v in metadata.items():
if not isinstance(k, str):
continue
all_dashes = k.replace('_', '-')
all_underscores = k.replace('-', '_')
if k != all_dashes and all_dashes in metadata:
raise BundleError('{n} metadata contains both {k} and {p}'.format(
n=node.name,
k='/'.join(path + [k]),
p='/'.join(path + [all_dashes]),
))
if k != all_underscores and all_underscores in metadata:
raise BundleError('{n} metadata contains both {k} and {p}'.format(
n=node.name,
k='/'.join(path + [k]),
p='/'.join(path + [all_underscores]),
))
if isinstance(v, Mapping):
test_underscore_vs_dash(
node,
v,
path + [k],
)
def test_node(repo, node, **kwargs):
test_underscore_vs_dash(
node,
node.metadata.get(tuple()),
)
io.stdout('{x} {node} metadata contains no dashes-vs-underscores errors'.format(
x=green(""),
node=bold(node.name),
))

View file

@ -14,7 +14,7 @@ nodes['home.kodi-wohnzimmer'] = {
'packages': {
'intel-media-va-driver-non-free': {},
},
'unattended_upgrades': {
'unattended-upgrades': {
'day': 6,
'hour': 2,
},

View file

@ -26,10 +26,10 @@ nodes['home.nas'] = {
},
},
'apt': {
'unattended_upgrades': {
'unattended-upgrades': {
'day': 6,
# requires manual decryption of zfs after reboot
'reboot-enabled': False,
'reboot_enabled': False,
},
'packages': {
'mpv': {},

View file

@ -13,7 +13,7 @@ nodes['htz-hel.backup-kunsi'] = {
'unattended-upgrades': {
# requires manual apply after reboot to unlock dm-crypt
# devices
'reboot-enabled': False,
'reboot_enabled': False,
},
},
'interfaces': {

View file

@ -16,7 +16,7 @@ nodes['htz-hel.backup-sophie'] = {
'unattended-upgrades': {
# requires manual apply after reboot to unlock dm-crypt
# devices
'reboot-enabled': False,
'reboot_enabled': False,
},
},
'backups': {

View file

@ -9,13 +9,6 @@ nodes['voc.infobeamer-cms'] = {
'webserver',
},
'metadata': {
'apt': {
# Move patchday to somewhere where the possibility of
# clashing with actual events is less likely.
'unattended_upgrades': {
'day': 1,
},
},
'backups': {
'exclude_from_backups': True,
},

View file

@ -14,13 +14,6 @@ nodes['voc.pretalx'] = {
'sshmon',
},
'metadata': {
'apt': {
# Move patchday to somewhere where the possibility of
# clashing with actual events is less likely.
'unattended_upgrades': {
'day': 1,
},
},
'check-mail-received': {
't-online': {
'email': 'franzi.kunsmann@t-online.de',