This commit is contained in:
LunarAkai 2025-03-17 22:42:43 +01:00
commit 51f2c91f2b
4 changed files with 78 additions and 0 deletions

View file

@ -0,0 +1,39 @@
- name: update server
hosts: main,vps,home
become: yes
tasks:
- name: perfom a dist-upgrade (apt)
ansible.builtin.apt:
upgrade: dist
update_cache: yes
when: ansible_pkg_mgr == 'apt'
- name: upgrade all packages (dnf)
ansible.builtin.dnf:
name: "*"
state: latest
when: ansible_pkg_mgr == 'dnf'
- 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 required)
ansible.builtin.reboot:
when: reboot_required_file.stat.exists == true
- name: remove dependencies that are no longer required. (apt)
ansible.builtin.apt:
autoremove: yes
when: ansible_pkg_mgr == 'apt'
- name: remove dependencies that are no longer required (dnf)
ansible.builtin.dnf:
autoremove: yes
when: ansible_pkg_mgr == 'dnf'