unattended upgrades

This commit is contained in:
cronekorkn 2022-09-18 19:07:13 +02:00
parent 388edf0ea6
commit 779e3ff8d4
Signed by: cronekorkn
SSH key fingerprint: SHA256:v0410ZKfuO1QHdgKBsdQNF64xmTxOF8osF1LIqwTcVw
4 changed files with 37 additions and 2 deletions

View file

@ -0,0 +1,2 @@
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";

View file

@ -0,0 +1,3 @@
Unattended-Upgrade::Origins-Pattern {
"origin=*";
};

View file

@ -103,3 +103,27 @@ for package, options in node.metadata.get('apt/packages', {}).items():
'action:apt_update', 'action:apt_update',
}, },
} }
# unattended upgrades
#
# unattended-upgrades.service: delays shutdown if necessary
# apt-daily.timer: performs apt update
# apt-daily-upgrade.timer: performs apt upgrade
files['/etc/apt/apt.conf.d/20auto-upgrades'] = {}
files['/etc/apt/apt.conf.d/50unattended-upgrades'] = {}
svc_systemd['unattended-upgrades.service'] = {
'needs': [
'pkg_apt:unattended-upgrades',
],
}
svc_systemd['apt-daily.timer'] = {
'needs': [
'pkg_apt:unattended-upgrades',
],
}
svc_systemd['apt-daily-upgrade.timer'] = {
'needs': [
'pkg_apt:unattended-upgrades',
],
}

View file

@ -1,6 +1,8 @@
defaults = { defaults = {
'apt': { 'apt': {
'packages': {}, 'packages': {
'unattended-upgrades': {},
},
'sources': set(), 'sources': set(),
}, },
'monitoring': { 'monitoring': {
@ -8,12 +10,16 @@ defaults = {
'apt upgradable': { 'apt upgradable': {
'vars.command': '/usr/lib/nagios/plugins/check_apt_upgradable', 'vars.command': '/usr/lib/nagios/plugins/check_apt_upgradable',
'vars.sudo': True, 'vars.sudo': True,
'check_interval': '1d', 'check_interval': '1h',
}, },
'current kernel': { 'current kernel': {
'vars.command': 'ls /boot/vmlinuz-* | sort -V | tail -n 1 | xargs -n1 basename | cut -d "-" -f 2- | grep -q "^$(uname -r)$"', 'vars.command': 'ls /boot/vmlinuz-* | sort -V | tail -n 1 | xargs -n1 basename | cut -d "-" -f 2- | grep -q "^$(uname -r)$"',
'check_interval': '1h', 'check_interval': '1h',
}, },
'apt reboot-required': {
'vars.command': 'ls /var/run/reboot-required 2> /dev/null && exit 1 || exit 0',
'check_interval': '1h',
},
}, },
}, },
} }