From acc5e579f6d3d2c64952babb1178d0051e15018c Mon Sep 17 00:00:00 2001 From: Lihai Tu <92532497+tu1h@users.noreply.github.com> Date: Thu, 29 Aug 2024 22:47:39 +0800 Subject: [PATCH] Add conditional checking on ubuntu kernel unattended_upgrades disabling (#11479) Signed-off-by: tu1h --- roles/bootstrap-os/tasks/debian.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/roles/bootstrap-os/tasks/debian.yml b/roles/bootstrap-os/tasks/debian.yml index 5835ae164..9ede45f9b 100644 --- a/roles/bootstrap-os/tasks/debian.yml +++ b/roles/bootstrap-os/tasks/debian.yml @@ -63,9 +63,17 @@ - '"value from" in bootstrap_update_apt_result.stdout' ignore_errors: true +- name: Check unattended-upgrades file exist + stat: + path: /etc/apt/apt.conf.d/50unattended-upgrades + register: unattended_upgrades_file_stat + when: + - os_release_dict['ID'] == 'ubuntu' + - ubuntu_kernel_unattended_upgrades_disabled + - name: Disable kernel unattended-upgrades lineinfile: - path: /etc/apt/apt.conf.d/50unattended-upgrades + path: "{{ unattended_upgrades_file_stat.stat.path }}" insertafter: "Unattended-Upgrade::Package-Blacklist" line: '"linux-";' state: present @@ -73,3 +81,4 @@ when: - os_release_dict['ID'] == 'ubuntu' - ubuntu_kernel_unattended_upgrades_disabled + - unattended_upgrades_file_stat.stat.exists