From 8218ec1b7185c4d7e48025b65f956d9102c69255 Mon Sep 17 00:00:00 2001 From: shmick Date: Fri, 24 Nov 2023 08:44:50 +0200 Subject: [PATCH] Add autoremove and reboot --- hatarashi-pasokom.yaml | 43 ++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/hatarashi-pasokom.yaml b/hatarashi-pasokom.yaml index 3f1736b..27a87cf 100644 --- a/hatarashi-pasokom.yaml +++ b/hatarashi-pasokom.yaml @@ -1,18 +1,25 @@ ---- -- name: Update all packages (Debian) - hosts: takahe - become: yes - vars: - ansible_ssh_common_args: '-o StrictHostKeyChecking=no' - ansible_sudo_pass: "{{ ANSIBLE_SUDO_PASS }}" - - tasks: - - name: Update package cache - apt: - update_cache: yes - - - name: Upgrade all packages - apt: - upgrade: yes - autoremove: yes - autoclean: yes +--- +- hosts: takahe + gather_facts: yes + become: yes + vars: + ansible_ssh_common_args: '-o StrictHostKeyChecking=no' + ansible_sudo_pass: "{{ ANSIBLE_SUDO_PASS }}" + + tasks: + - name: Update all installed packages using APT module + apt: + name: '*' + state: latest + update_cache: yes + only_upgrade: yes + register: apt_update_status + + - name: Remove packages not needed anymore + apt: + autoremove: yes + + - name: Reboot when packages were updated + reboot: + post_reboot_delay: 60 + when: apt_update_status.changed \ No newline at end of file