Skip to content

Commit

Permalink
update_pgcluster.yml: Reboot node if it's required, e.g. kernel or se…
Browse files Browse the repository at this point in the history
…curity updates (#510)
  • Loading branch information
chuegel authored Nov 19, 2023
1 parent 90a9177 commit cc18794
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
26 changes: 26 additions & 0 deletions roles/update/tasks/system.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,30 @@
delay: 5
retries: 3
ignore_errors: true

- name: Check if a reboot is required
ansible.builtin.stat:
path: /var/run/reboot-required
register: reboot_required_debian
changed_when: false
when:
- ansible_os_family == "Debian"
- ansible_virtualization_type not in ['container', 'docker', 'lxc', 'podman'] # exclude for containers to prevent test failures in CI.

- name: Check if a reboot is required
ansible.builtin.command: needs-restarting -r
register: reboot_required_rhel
failed_when: false
changed_when: false
when:
- ansible_os_family == "RedHat"
- ansible_virtualization_type not in ['container', 'docker', 'lxc', 'podman'] # exclude for containers to prevent test failures in CI.

- name: Rebooting host
ansible.builtin.reboot:
msg: "Reboot initiated by Ansible due to required system updates"
reboot_timeout: 1800 # 30 minutes
test_command: uptime
when: (reboot_required_debian.stat.exists is defined and reboot_required_debian.stat.exists) or
(reboot_required_rhel.rc is defined and reboot_required_rhel.rc != 0)
...
3 changes: 3 additions & 0 deletions vars/RedHat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,18 @@ os_specific_packages:
- libselinux-python
- libsemanage-python
- policycoreutils-python
- yum-utils
RedHat-8:
- python2
- python3-libselinux
- python3-libsemanage
- python3-policycoreutils
- dnf-utils
RedHat-9:
- python3-libselinux
- python3-libsemanage
- python3-policycoreutils
- dnf-utils
system_packages:
- "{{ os_specific_packages[ansible_os_family ~ '-' ~ ansible_distribution_major_version] }}"
- python3
Expand Down

0 comments on commit cc18794

Please sign in to comment.