diff --git a/etc/kayobe/ansible/reboot.yml b/etc/kayobe/ansible/reboot.yml index 1af22e7f7..aa73a2617 100644 --- a/etc/kayobe/ansible/reboot.yml +++ b/etc/kayobe/ansible/reboot.yml @@ -9,9 +9,26 @@ ansible_user: "{{ bootstrap_user if reboot_with_bootstrap_user | bool else kayobe_ansible_user }}" ansible_ssh_common_args: "{{ '-o StrictHostKeyChecking=no' if reboot_with_bootstrap_user | bool else '' }}" ansible_python_interpreter: /usr/bin/python3 + confirm_reboot: false tags: - reboot tasks: + - name: Prompt to confirm reboot + ansible.builtin.pause: + prompt: > + The following hosts will be rebooted: + {{ play_hosts | join(', ') }} + If you want to proceed type: yes + register: pause_prompt + when: not confirm_reboot + + - name: Fail if reboot is not confirmed + ansible.builtin.assert: + that: confirm_reboot | bool or pause_prompt.user_input == 'yes' + msg: > + Reboot has not been confirmed. You must either type 'yes' when + prompted, or set ``confirm_reboot: true``. + - name: Reboot and wait become: true ansible.builtin.reboot: diff --git a/etc/kayobe/environments/aufn-ceph/globals.yml b/etc/kayobe/environments/aufn-ceph/globals.yml index 5ef9e0cb4..f9166aaa0 100644 --- a/etc/kayobe/environments/aufn-ceph/globals.yml +++ b/etc/kayobe/environments/aufn-ceph/globals.yml @@ -13,3 +13,9 @@ os_distribution: "{{ lookup('pipe', '. /etc/os-release && echo $ID') | trim }}" os_release: >- {{ (lookup('pipe', '. /etc/os-release && echo $VERSION_CODENAME') | trim) if os_distribution == 'ubuntu' else (lookup('pipe', '. /etc/os-release && echo $VERSION_ID') | trim | split('.') | first) if os_distribution == 'rocky' }} + +############################################################################### +# Extra vars. + +# Don't prompt when rebooting hosts. +confirm_reboot: true diff --git a/etc/kayobe/environments/ci-aio/globals.yml b/etc/kayobe/environments/ci-aio/globals.yml index f65cba9f1..716dcb309 100644 --- a/etc/kayobe/environments/ci-aio/globals.yml +++ b/etc/kayobe/environments/ci-aio/globals.yml @@ -55,6 +55,12 @@ os_release: >- {{ (lookup('pipe', '. /etc/os-release && echo $VERSION_CODENAME') | trim) if os_distribution == 'ubuntu' else (lookup('pipe', '. /etc/os-release && echo $VERSION_ID') | trim | split('.') | first) if os_distribution == 'rocky' }} +############################################################################### +# Extra vars. + +# Don't prompt when rebooting hosts. +confirm_reboot: true + ############################################################################### # Dummy variable to allow Ansible to accept this file. workaround_ansible_issue_8743: yes diff --git a/etc/kayobe/environments/ci-builder/globals.yml b/etc/kayobe/environments/ci-builder/globals.yml index 9852cbd4d..f33fd5e05 100644 --- a/etc/kayobe/environments/ci-builder/globals.yml +++ b/etc/kayobe/environments/ci-builder/globals.yml @@ -7,3 +7,9 @@ # OS distribution name. Valid options are "rocky", "ubuntu". Default is # "rocky". os_distribution: "{{ lookup('pipe', '. /etc/os-release && echo $ID') | trim }}" + +############################################################################### +# Extra vars. + +# Don't prompt when rebooting hosts. +confirm_reboot: true diff --git a/etc/kayobe/environments/ci-doca-builder/globals.yml b/etc/kayobe/environments/ci-doca-builder/globals.yml new file mode 100644 index 000000000..f08f5e2e4 --- /dev/null +++ b/etc/kayobe/environments/ci-doca-builder/globals.yml @@ -0,0 +1,6 @@ +--- +############################################################################### +# Extra vars. + +# Don't prompt when rebooting hosts. +confirm_reboot: true diff --git a/etc/kayobe/environments/ci-multinode/globals.yml b/etc/kayobe/environments/ci-multinode/globals.yml index de497cb84..4dd25ddd3 100644 --- a/etc/kayobe/environments/ci-multinode/globals.yml +++ b/etc/kayobe/environments/ci-multinode/globals.yml @@ -63,6 +63,12 @@ stackhpc_barbican_role_id_file_path: "/tmp/barbican-role-id" # Enable rebooting to update SELinux state selinux_do_reboot: true +############################################################################### +# Extra vars. + +# Don't prompt when rebooting hosts. +confirm_reboot: true + ############################################################################### # Dummy variable to allow Ansible to accept this file. workaround_ansible_issue_8743: yes diff --git a/releasenotes/notes/add-confirmation-prompt-to-reboot.yml-4fd1ae8e8d360e57.yaml b/releasenotes/notes/add-confirmation-prompt-to-reboot.yml-4fd1ae8e8d360e57.yaml new file mode 100644 index 000000000..b696ac7c6 --- /dev/null +++ b/releasenotes/notes/add-confirmation-prompt-to-reboot.yml-4fd1ae8e8d360e57.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + A confirmation prompt has been added to ``reboot.yml`` to help avoid + rebooting the wrong hosts by mistake. This check can be skipped by setting + ``confirm_reboot: true``.