33 lines
892 B
YAML
33 lines
892 B
YAML
---
|
|
# update-system.yml
|
|
# Ansible playbook to apply system updates on Linux servers
|
|
# Supports Debian/Ubuntu and RedHat/CentOS/Fedora families
|
|
|
|
- name: Apply system updates
|
|
hosts: all
|
|
become: true
|
|
tasks:
|
|
- name: Upgrade all packages for Debian-based systems
|
|
ansible.builtin.apt:
|
|
update_cache: true
|
|
upgrade: dist
|
|
autoremove: true
|
|
autoclean: true
|
|
when: ansible_os_family == "Debian"
|
|
|
|
- name: Upgrade all packages for RedHat-based systems (dnf)
|
|
ansible.builtin.dnf:
|
|
name: "*"
|
|
state: latest # noqa package-latest
|
|
update_cache: true
|
|
when: ansible_pkg_mgr == "dnf"
|
|
|
|
- name: Upgrade all packages for RedHat-based systems (yum)
|
|
ansible.builtin.yum:
|
|
name: "*"
|
|
state: latest # noqa package-latest
|
|
update_cache: true
|
|
when: ansible_pkg_mgr == "yum"
|
|
|
|
# End of playbook
|