Files
Ansible-Minecraft-Server/roles/05-update/tasks/02-check-system-updates.yml
hcornet 7a2ccb537b
Some checks failed
Ansible Minecraft CI/CD Pipeline / Ansible Lint Check (push) Successful in 58s
Ansible Minecraft CI/CD Pipeline / Project Structure Validation (push) Failing after 3s
Ansible Minecraft CI/CD Pipeline / Security Scan (push) Successful in 4s
Ansible Minecraft CI/CD Pipeline / Deploy to Staging (push) Has been skipped
Ansible Minecraft CI/CD Pipeline / Deploy to Production (push) Has been skipped
Ansible Minecraft CI/CD Pipeline / Backup System Check (push) Has been skipped
test other version
2025-08-26 21:59:21 +02:00

41 lines
1.2 KiB
YAML

---
- name: Update apt cache
ansible.builtin.apt:
update_cache: true
when: ansible_os_family == "Debian"
- name: Check for available system updates
ansible.builtin.shell: |
apt list --upgradable 2>/dev/null | grep -v "Listing..." | wc -l
register: available_updates_count
changed_when: false
when: ansible_os_family == "Debian"
- name: Display available updates count
ansible.builtin.debug:
msg: "{{ available_updates_count.stdout }} system updates available"
when: available_updates_count is defined
- name: Apply system updates if auto-update enabled
ansible.builtin.apt:
upgrade: dist
autoremove: true
autoclean: true
when:
- system_update_auto | bool
- ansible_os_family == "Debian"
- available_updates_count.stdout | int > 0
register: system_update_result
- name: Check if reboot is required
ansible.builtin.stat:
path: /var/run/reboot-required
register: reboot_required_file
when: system_reboot_required_check | bool
- name: Warn about required reboot
ansible.builtin.debug:
msg: "ATTENTION: System reboot is required to complete updates"
when:
- reboot_required_file is defined
- reboot_required_file.stat.exists