Files
ansible-playbooks/roles/os-updates/tasks/upgrade_packages.yml
T
2026-02-20 22:19:57 +01:00

27 lines
773 B
YAML

- name: Upgrade all installed packages
apt:
upgrade: full
update_cache: yes
notify:
- apt cleanup
- name: Check if a kernel update is available
shell: |
dpkg -l | grep -E '^ii' | grep 'linux-image-[0-9]' | awk '{print $2}' | sort | tail -n 1
register: latest_kernel
when: ansible_virtualization_type != 'lxc'
- name: Check if running kernel matches the latest installed kernel
shell: |
echo "{{ latest_kernel.stdout }}" | grep -c $(uname -r)
register: kernel_match
changed_when: false
ignore_errors: true
when: ansible_virtualization_type != 'lxc'
- name: Mark reboot required if a new kernel is installed
set_fact:
reboot_required: "yes"
when:
- ansible_virtualization_type != 'lxc'
- kernel_match.stdout == "0"