Add update-system Ansible playbook for applying system updates
This commit is contained in:
@@ -0,0 +1,44 @@
|
|||||||
|
---
|
||||||
|
# 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: Update package cache for Debian-based systems
|
||||||
|
ansible.builtin.apt:
|
||||||
|
update_cache: true
|
||||||
|
when: ansible_os_family == "Debian"
|
||||||
|
|
||||||
|
- name: Upgrade all packages for Debian-based systems
|
||||||
|
ansible.builtin.apt:
|
||||||
|
upgrade: dist
|
||||||
|
autoremove: true
|
||||||
|
autoclean: true
|
||||||
|
when: ansible_os_family == "Debian"
|
||||||
|
|
||||||
|
- name: Update package cache for RedHat-based systems (dnf)
|
||||||
|
ansible.builtin.dnf:
|
||||||
|
update_cache: true
|
||||||
|
when: ansible_pkg_mgr == "dnf"
|
||||||
|
|
||||||
|
- name: Upgrade all packages for RedHat-based systems (dnf)
|
||||||
|
ansible.builtin.dnf:
|
||||||
|
name: "*"
|
||||||
|
state: latest # noqa package-latest
|
||||||
|
when: ansible_pkg_mgr == "dnf"
|
||||||
|
|
||||||
|
- name: Update package cache for RedHat-based systems (yum)
|
||||||
|
ansible.builtin.yum:
|
||||||
|
update_cache: true
|
||||||
|
when: ansible_pkg_mgr == "yum"
|
||||||
|
|
||||||
|
- name: Upgrade all packages for RedHat-based systems (yum)
|
||||||
|
ansible.builtin.yum:
|
||||||
|
name: "*"
|
||||||
|
state: latest # noqa package-latest
|
||||||
|
when: ansible_pkg_mgr == "yum"
|
||||||
|
|
||||||
|
# End of playbook
|
||||||
Reference in New Issue
Block a user