43 lines
951 B
YAML
43 lines
951 B
YAML
---
|
|
- name: Update, Upgrade, Autoremove, and Autoclean
|
|
hosts: all
|
|
become: true
|
|
|
|
tasks:
|
|
- name: Update package index
|
|
apt:
|
|
update_cache: yes
|
|
|
|
- name: Upgrade packages
|
|
apt:
|
|
upgrade: yes
|
|
|
|
- name: Perform a distro upgrade
|
|
ansible.builtin.apt:
|
|
upgrade: dist
|
|
update_cache: yes
|
|
|
|
- name: Remove dependencies that are no longer needed
|
|
ansible.builtin.apt:
|
|
autoremove: yes
|
|
purge: true
|
|
|
|
- name: Update all packages to their latest version
|
|
ansible.builtin.apt:
|
|
name: "*"
|
|
state: latest
|
|
|
|
- name: Run the equivalent of "apt-get clean" as a separate step
|
|
ansible.builtin.apt:
|
|
clean: yes
|
|
|
|
- name: Check if a reboot is required
|
|
ansible.builtin.stat:
|
|
path: /var/run/reboot-required
|
|
get_checksum: no
|
|
register: reboot_required_file
|
|
|
|
- name: Reboot the server (if necessary)
|
|
ansible.builtin.reboot:
|
|
when: reboot_required_file.stat.exists == true
|