diff --git a/playbooks/update.yaml b/playbooks/update.yaml index e69de29..e2cd1fe 100644 --- a/playbooks/update.yaml +++ b/playbooks/update.yaml @@ -0,0 +1,35 @@ +--- +- name: Update and upgrade Debian/Ubuntu systems + hosts: all + become: true + gather_facts: true + + tasks: + - name: Update APT package cache + ansible.builtin.apt: + update_cache: true + cache_valid_time: 3600 + + - name: Upgrade installed packages + ansible.builtin.apt: + upgrade: true + + - name: Remove unused packages + ansible.builtin.apt: + autoremove: true + purge: false + + - name: Clean APT cache + ansible.builtin.apt: + autoclean: true + + - name: Check if reboot is required + ansible.builtin.stat: + path: /var/run/reboot-required + register: reboot_required + + - name: Display reboot status + ansible.builtin.debug: + msg: > + A reboot is required on this host. + when: reboot_required.stat.exists \ No newline at end of file