From fcad5b93547d48d9a897e9abdd371e19a8c27703 Mon Sep 17 00:00:00 2001 From: Marius Melzer Date: Sat, 20 Apr 2024 15:24:38 +0200 Subject: [PATCH] Add unattended upgrades Enable unattended upgrades and triggers unattended reboots (23:55 after an upgrade which needs reboot). Attention: this is specific to debian-style linux systems (Debian, Ubuntu,...). --- .../unattended-upgrades/files/20auto-upgrades | 2 ++ roles/unattended-upgrades/tasks/main.json | 33 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 roles/unattended-upgrades/files/20auto-upgrades create mode 100644 roles/unattended-upgrades/tasks/main.json diff --git a/roles/unattended-upgrades/files/20auto-upgrades b/roles/unattended-upgrades/files/20auto-upgrades new file mode 100644 index 0000000..8d6d7c8 --- /dev/null +++ b/roles/unattended-upgrades/files/20auto-upgrades @@ -0,0 +1,2 @@ +APT::Periodic::Update-Package-Lists "1"; +APT::Periodic::Unattended-Upgrade "1"; diff --git a/roles/unattended-upgrades/tasks/main.json b/roles/unattended-upgrades/tasks/main.json new file mode 100644 index 0000000..7706bc3 --- /dev/null +++ b/roles/unattended-upgrades/tasks/main.json @@ -0,0 +1,33 @@ +[ + { + "name": "Allow unattended reboots (1)", + "lineinfile": { + "dest": "/etc/apt/apt.conf.d/50unattended-upgrades", + "regexp": "^(//)?Unattended-Upgrade::Automatic-Reboot ", + "line": "Unattended-Upgrade::Automatic-Reboot \"true\";" + } + }, + { + "name": "Allow unattended reboots (2)", + "lineinfile": { + "dest": "/etc/apt/apt.conf.d/50unattended-upgrades", + "regexp": "^(//)?Unattended-Upgrade::Automatic-Reboot-Time ", + "line": "Unattended-Upgrade::Automatic-Reboot-Time \"23:55\";" + } + }, + { + "name": "Allow more origins for updates", + "lineinfile": { + "dest": "/etc/apt/apt.conf.d/50unattended-upgrades", + "regexp": "^(//\\s*)?\"\\$\\{distro_id\\}:\\$\\{distro_codename\\}-updates\";", + "line": "\"${distro_id}:${distro_codename}-updates\";" + } + }, + { + "name": "Enable unattended upgrades", + "copy": { + "src": "20auto-upgrades", + "dest": "/etc/apt/apt.conf.d/20auto-upgrades" + } + } +]