ansible-homelab/debian-update.yml

28 lines
655 B
YAML
Raw Normal View History

2024-12-19 09:29:44 +01:00
---
2025-01-08 01:26:36 +01:00
- hosts: servers
2024-12-19 09:29:44 +01:00
gather_facts: true
become: true
tasks:
2025-01-08 01:26:36 +01:00
- name: Perform a cache update
ansible.builtin.apt:
update_cache: true
2024-12-19 09:29:44 +01:00
- name: Perform a dist-upgrade
ansible.builtin.apt:
upgrade: dist
- 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