ansible-homelab/debian-update.yml
2024-10-26 13:35:07 -05:00

25 lines
593 B
YAML

---
- hosts: servers
gather_facts: true
become: true
tasks:
- name: Perform a dist-upgrade
ansible.builtin.apt:
upgrade: dist
update_cache: true
- name: Check if reboot is required
ansible.builtin.stat:
path: /var/run/reboot-required
get_checksum: false
register: reboot_required_file
- name: Reboot the server (if required)
ansible.builtin.reboot:
when: reboot_required_file.stat.exists == true
- name: Remove dependencies that are no longer required
ansible.builtin.apt:
autoremove: true