Skip to content

Commit 54b229f

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 54b229f

File tree

7 files changed

+43
-0
lines changed

7 files changed

+43
-0
lines changed

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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
# Don't prompt when rebooting hosts.
3+
confirm_reboot: "yes"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
# Don't prompt when rebooting hosts.
3+
confirm_reboot: "yes"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
# Don't prompt when rebooting hosts.
3+
confirm_reboot: "yes"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
# Don't prompt when rebooting hosts.
3+
confirm_reboot: "yes"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
---
22
cephadm_host_labels: []
3+
4+
# Don't prompt when rebooting hosts.
5+
confirm_reboot: "yes"
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)