diff --git a/bundles/apt/files/20auto-upgrades b/bundles/apt/files/20auto-upgrades new file mode 100644 index 0000000..8d6d7c8 --- /dev/null +++ b/bundles/apt/files/20auto-upgrades @@ -0,0 +1,2 @@ +APT::Periodic::Update-Package-Lists "1"; +APT::Periodic::Unattended-Upgrade "1"; diff --git a/bundles/apt/files/50unattended-upgrades b/bundles/apt/files/50unattended-upgrades new file mode 100644 index 0000000..16156c7 --- /dev/null +++ b/bundles/apt/files/50unattended-upgrades @@ -0,0 +1,3 @@ +Unattended-Upgrade::Origins-Pattern { + "origin=*"; +}; diff --git a/bundles/apt/items.py b/bundles/apt/items.py index d81a39b..115fc2f 100644 --- a/bundles/apt/items.py +++ b/bundles/apt/items.py @@ -103,3 +103,27 @@ for package, options in node.metadata.get('apt/packages', {}).items(): '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', + ], +} diff --git a/bundles/apt/metadata.py b/bundles/apt/metadata.py index bf1fa14..7d510de 100644 --- a/bundles/apt/metadata.py +++ b/bundles/apt/metadata.py @@ -1,6 +1,8 @@ defaults = { 'apt': { - 'packages': {}, + 'packages': { + 'unattended-upgrades': {}, + }, 'sources': set(), }, 'monitoring': { @@ -8,12 +10,16 @@ defaults = { 'apt upgradable': { 'vars.command': '/usr/lib/nagios/plugins/check_apt_upgradable', 'vars.sudo': True, - 'check_interval': '1d', + 'check_interval': '1h', }, 'current kernel': { 'vars.command': 'ls /boot/vmlinuz-* | sort -V | tail -n 1 | xargs -n1 basename | cut -d "-" -f 2- | grep -q "^$(uname -r)$"', 'check_interval': '1h', }, + 'apt reboot-required': { + 'vars.command': 'ls /var/run/reboot-required 2> /dev/null && exit 1 || exit 0', + 'check_interval': '1h', + }, }, }, }