Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update_pgcluster.yml: Reboot node if it's required, e.g. kernel or security updates #510

Merged
merged 3 commits into from
Nov 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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