Add conditional checking on ubuntu kernel unattended_upgrades disabling (#11479)

Signed-off-by: tu1h <lihai.tu@daocloud.io>
pull/11486/head
Lihai Tu 2024-08-29 22:47:39 +08:00 committed by GitHub
parent 60b323b17f
commit acc5e579f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 1 deletions

View File

@ -63,9 +63,17 @@
- '"value from" in bootstrap_update_apt_result.stdout' - '"value from" in bootstrap_update_apt_result.stdout'
ignore_errors: true 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 - name: Disable kernel unattended-upgrades
lineinfile: lineinfile:
path: /etc/apt/apt.conf.d/50unattended-upgrades path: "{{ unattended_upgrades_file_stat.stat.path }}"
insertafter: "Unattended-Upgrade::Package-Blacklist" insertafter: "Unattended-Upgrade::Package-Blacklist"
line: '"linux-";' line: '"linux-";'
state: present state: present
@ -73,3 +81,4 @@
when: when:
- os_release_dict['ID'] == 'ubuntu' - os_release_dict['ID'] == 'ubuntu'
- ubuntu_kernel_unattended_upgrades_disabled - ubuntu_kernel_unattended_upgrades_disabled
- unattended_upgrades_file_stat.stat.exists