Update playbooks/update.yaml
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user