Skip to content

Commit dbb62f0

Browse files
committed
Add a confirmation prompt to reboot.yml
This is a risky playbook to run without confirmation, especially as it targets all hosts when not using a limit.
1 parent 9f6c4ef commit dbb62f0

File tree

5 files changed

+33
-2
lines changed

5 files changed

+33
-2
lines changed

.github/workflows/package-build-ofed.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ jobs:
230230
run: |
231231
source venvs/kayobe/bin/activate &&
232232
source src/kayobe-config/kayobe-env --environment ci-doca-builder &&
233-
kayobe playbook run src/kayobe-config/etc/kayobe/ansible/reboot.yml
233+
kayobe playbook run src/kayobe-config/etc/kayobe/ansible/reboot.yml \
234+
-e confirm_reboot=yes
234235
env:
235236
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }}
236237

.github/workflows/stackhpc-all-in-one.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,8 @@ jobs:
291291
-v $(pwd):/stack/kayobe-automation-env/src/kayobe-config \
292292
-e KAYOBE_ENVIRONMENT -e KAYOBE_VAULT_PASSWORD -e KAYOBE_AUTOMATION_SSH_PRIVATE_KEY \
293293
${{ steps.kayobe_image.outputs.kayobe_image }} \
294-
/stack/kayobe-automation-env/src/kayobe-config/.automation/pipeline/playbook-run.sh etc/kayobe/ansible/reboot.yml -e reboot_with_bootstrap_user=true
294+
/stack/kayobe-automation-env/src/kayobe-config/.automation/pipeline/playbook-run.sh etc/kayobe/ansible/reboot.yml \
295+
-e reboot_with_bootstrap_user=true -e confirm_reboot=yes
295296
env:
296297
KAYOBE_AUTOMATION_SSH_PRIVATE_KEY: ${{ steps.ssh_key.outputs.ssh_key }}
297298

etc/kayobe/ansible/fix-hostname.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@
2727
vars:
2828
reboot_hosts: fix-hostname
2929
reboot_with_bootstrap_user: true
30+
confirm_reboot: "yes"
3031
when: current_hostname.stdout != inventory_hostname

etc/kayobe/ansible/reboot.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,26 @@
99
ansible_user: "{{ bootstrap_user if reboot_with_bootstrap_user | bool else kayobe_ansible_user }}"
1010
ansible_ssh_common_args: "{{ '-o StrictHostKeyChecking=no' if reboot_with_bootstrap_user | bool else '' }}"
1111
ansible_python_interpreter: /usr/bin/python3
12+
confirm_reboot: False
1213
tags:
1314
- reboot
1415
tasks:
16+
- name: Prompt to confirm reboot
17+
ansible.builtin.pause:
18+
prompt: >
19+
The following hosts will be rebooted:
20+
{{ play_hosts | join(', ') }}
21+
If you want to proceed type: yes
22+
register: pause_prompt
23+
when: not confirm_reboot
24+
25+
- name: Fail if reboot is not confirmed
26+
ansible.builtin.assert:
27+
that: confirm_reboot == 'yes' or pause_prompt.user_input == 'yes'
28+
msg: >
29+
Reboot has not been confirmed. You must either type 'yes' when
30+
prompted, or set ``confirm_reboot=yes``.
31+
1532
- name: Reboot and wait
1633
become: true
1734
ansible.builtin.reboot:
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
features:
3+
- |
4+
A confirmation prompt has been added to ``reboot.yml`` to help avoid
5+
rebooting the wrong hosts by mistake. This check can be skipped by setting
6+
``confirm_reboot=yes``.
7+
upgrade:
8+
- |
9+
A confirmation prompt has been added to ``reboot.yml`` to help avoid
10+
rebooting the wrong hosts by mistake. This check can be skipped by setting
11+
``confirm_reboot=yes``.

0 commit comments

Comments
 (0)