Skip to content

Commit

Permalink
updating reboot logic to minimize the chance of an unnecessary reboot
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Leiner committed Apr 12, 2024
1 parent 8cf5b3d commit 6d4728c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
5 changes: 4 additions & 1 deletion roles/rke2_common/tasks/cis-hardening.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@
name: systemd-sysctl
when: sysctl_operation_yum.changed or sysctl_operation_tarball.changed

# Per CIS hardening guide, if Kubernetes is already running, making changes to sysctl can result in unexpected
# side-effects. Rebooting node if RKE2 is already running to prevent potential issues whereas before we were
# always rebooting, even if the node was brand new and RKE2 not running yet.
- name: Reboot the machine (Wait for 5 min)
ansible.builtin.reboot:
reboot_timeout: 300
when: sysctl_operation_yum.changed or sysctl_operation_tarball.changed
when: (sysctl_operation_yum.changed or sysctl_operation_tarball.changed) and rke2_running is defined and rke2_running

Check failure on line 55 in roles/rke2_common/tasks/cis-hardening.yml

View workflow job for this annotation

GitHub Actions / Lint for push

yaml[line-length]

Line too long (123 > 120 characters)

Check warning on line 55 in roles/rke2_common/tasks/cis-hardening.yml

View workflow job for this annotation

GitHub Actions / Lint for push

55:121 [line-length] line too long (123 > 120 characters)

Check failure on line 55 in roles/rke2_common/tasks/cis-hardening.yml

View workflow job for this annotation

GitHub Actions / Lint for PR

yaml[line-length]

Line too long (123 > 120 characters)

Check warning on line 55 in roles/rke2_common/tasks/cis-hardening.yml

View workflow job for this annotation

GitHub Actions / Lint for PR

55:121 [line-length] line too long (123 > 120 characters)

Check failure on line 55 in roles/rke2_common/tasks/cis-hardening.yml

View workflow job for this annotation

GitHub Actions / Lint for PR

yaml[line-length]

Line too long (123 > 120 characters)

Check warning on line 55 in roles/rke2_common/tasks/cis-hardening.yml

View workflow job for this annotation

GitHub Actions / Lint for PR

55:121 [line-length] line too long (123 > 120 characters)
14 changes: 14 additions & 0 deletions roles/rke2_common/tasks/previous_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
ansible_facts.services["rke2-server.service"] is defined
and not ansible_facts.services["rke2-server.service"].status == 'disabled'
- name: Set fact if rke2-server is running
ansible.builtin.set_fact:
rke2_running: true
when: >
ansible_facts.services["rke2-server.service"] is defined
and ansible_facts.services["rke2-server.service"].state == 'running'
- name: Check if rke2-agent is previously installed
ansible.builtin.debug:
msg: "rke2-agent is already installed. Skipping installation steps."
Expand All @@ -28,6 +35,13 @@
ansible_facts.services["rke2-agent.service"] is defined
and not ansible_facts.services["rke2-agent.service"].status == 'disabled'
- name: Set fact if rke2-agent is running
ansible.builtin.set_fact:
rke2_running: true
when: >
ansible_facts.services["rke2-agent.service"] is defined
and ansible_facts.services["rke2-agent.service"].state == 'running'
- name: Check for the rke2 binary
ansible.builtin.stat:
path: /usr/local/bin/rke2
Expand Down

0 comments on commit 6d4728c

Please sign in to comment.