Files
ansible-playbooks/roles/os-updates/tasks/upgrade_packages.yml
T
2026-05-08 21:27:10 +02:00

30 lines
847 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
failed_when: false
when: ansible_facts['virtualization_type'] != 'lxc'
- name: Mark reboot required if a new kernel is installed
set_fact:
reboot_required: "yes"
changed_when: true
notify:
- Reboot system
when:
- ansible_facts['virtualization_type'] != 'lxc'
- (kernel_match.stdout | int) == 0