Skip to content

Commit e7b235d

Browse files
authored
Merge pull request #1576 from stackhpc/add-confirmation-to-reboot
Add a confirmation prompt to reboot.yml
2 parents 7741f2f + 424cc35 commit e7b235d

File tree

7 files changed

+53
-0
lines changed

7 files changed

+53
-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 | bool 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: true``.
31+
1532
- name: Reboot and wait
1633
become: true
1734
ansible.builtin.reboot:

etc/kayobe/environments/aufn-ceph/globals.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,9 @@ os_distribution: "{{ lookup('pipe', '. /etc/os-release && echo $ID') | trim }}"
1313
os_release: >-
1414
{{ (lookup('pipe', '. /etc/os-release && echo $VERSION_CODENAME') | trim) if os_distribution == 'ubuntu' else
1515
(lookup('pipe', '. /etc/os-release && echo $VERSION_ID') | trim | split('.') | first) if os_distribution == 'rocky' }}
16+
17+
###############################################################################
18+
# Extra vars.
19+
20+
# Don't prompt when rebooting hosts.
21+
confirm_reboot: true

etc/kayobe/environments/ci-aio/globals.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ os_release: >-
5555
{{ (lookup('pipe', '. /etc/os-release && echo $VERSION_CODENAME') | trim) if os_distribution == 'ubuntu' else
5656
(lookup('pipe', '. /etc/os-release && echo $VERSION_ID') | trim | split('.') | first) if os_distribution == 'rocky' }}
5757
58+
###############################################################################
59+
# Extra vars.
60+
61+
# Don't prompt when rebooting hosts.
62+
confirm_reboot: true
63+
5864
###############################################################################
5965
# Dummy variable to allow Ansible to accept this file.
6066
workaround_ansible_issue_8743: yes

etc/kayobe/environments/ci-builder/globals.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,9 @@
77
# OS distribution name. Valid options are "rocky", "ubuntu". Default is
88
# "rocky".
99
os_distribution: "{{ lookup('pipe', '. /etc/os-release && echo $ID') | trim }}"
10+
11+
###############################################################################
12+
# Extra vars.
13+
14+
# Don't prompt when rebooting hosts.
15+
confirm_reboot: true
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
###############################################################################
3+
# Extra vars.
4+
5+
# Don't prompt when rebooting hosts.
6+
confirm_reboot: true

etc/kayobe/environments/ci-multinode/globals.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ stackhpc_barbican_role_id_file_path: "/tmp/barbican-role-id"
6363
# Enable rebooting to update SELinux state
6464
selinux_do_reboot: true
6565

66+
###############################################################################
67+
# Extra vars.
68+
69+
# Don't prompt when rebooting hosts.
70+
confirm_reboot: true
71+
6672
###############################################################################
6773
# Dummy variable to allow Ansible to accept this file.
6874
workaround_ansible_issue_8743: yes
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
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: true``.

0 commit comments

Comments
 (0)