deploy-base/roles/update-packages/tasks/main.yml
2025-07-27 12:57:42 -05:00

37 lines
1.2 KiB
YAML

---
- block:
- name: Update packages (Fedora Atomic)
community.general.atomic_host:
revision: latest
when: ansible_distribution == 'Fedora' and ansible_local.os.is_atomic
register: atomic_host_upgraded
- name: Refresh and update packages (DNF driven distros)
ansible.builtin.dnf:
name: "*"
state: latest
update_cache: true
when: ansible_distribution in ['CentOS', 'Fedora', 'Red Hat Enterprise Linux', 'RedHat'] and not ansible_local.os.is_atomic
register: fedora_upgraded
- name: Update packages (generic - non-atomic/dnf)
ansible.builtin.package:
name: '*'
state: latest
when: ansible_distribution in ["Debian", "Ubuntu"]
register: host_upgraded
- name: Reboot updated hosts
ansible.builtin.shell: nohup bash -c "sleep 2 && shutdown -r now" &
register: host_reset
when: (atomic_host_upgraded is changed) or (host_upgraded is changed) or (fedora_upgraded is changed)
- name: Wait for rebooted host to return
ansible.builtin.wait_for_connection:
timeout: 300
delay: 20
when: host_reset is changed
become: true
tags:
- update