refactor: update APT tasks for better package management in linux_updates.yaml
This commit is contained in:
+10
-8
@@ -23,16 +23,18 @@
|
||||
- hosts: debianhosts
|
||||
gather_facts: no
|
||||
tasks:
|
||||
- name: Update all installed packages using APT module
|
||||
apt:
|
||||
name: '*'
|
||||
state: latest
|
||||
- name: Update apt package cache
|
||||
ansible.builtin.apt:
|
||||
update_cache: yes
|
||||
only_upgrade: yes
|
||||
register: apt_update_status
|
||||
cache_valid_time: 3600 # Update cache if it's older than 1 hour (3600 seconds)
|
||||
|
||||
- name: Remove packages not needed anymore
|
||||
apt:
|
||||
- name: Upgrade all packages to the latest version
|
||||
ansible.builtin.apt:
|
||||
upgrade: dist # Equivalent to apt-get dist-upgrade
|
||||
force_apt_get: yes # Ensure apt-get is used instead of aptitud
|
||||
|
||||
- name: Clean up unused dependencies
|
||||
ansible.builtin.apt:
|
||||
autoremove: yes
|
||||
|
||||
- name: Reboot when packages were updated
|
||||
|
||||
Reference in New Issue
Block a user