Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

Use ansible reboot module #55

Closed
Klaas- opened this issue Oct 15, 2019 · 3 comments
Closed

Use ansible reboot module #55

Klaas- opened this issue Oct 15, 2019 · 3 comments
Assignees

Comments

@Klaas-
Copy link
Contributor

Klaas- commented Oct 15, 2019

As soon as you don't support ansible 2.6 anymore you can move to reboot module

- name: Reboot if required
block:
# Reboot the server now and wait until it is back
# inspired by https://support.ansible.com/hc/en-us/articles/201958037-Reboot-a-server-and-wait-for-it-to-come-back
- name: restart machine if required
shell: sleep 2 && shutdown -r now "Ansible updates triggered"
async: 1
poll: 0
become: true
ignore_errors: true
- name: waiting for server to come back
local_action: wait_for host={{ inventory_hostname }} port=22 state=started delay=90 sleep=2 timeout={{ sap_hana_preconfigure_reboot_timeout }}
become: false
when: sap_hana_preconfigure_reboot_after_update == true and sap_hana_preconfigure_register_reboot_required.rc == 1

would become:

- name: Reboot if required
  reboot:
    reboot_timeout: "{{ sap_hana_preconfigure_reboot_timeout }}"
  when: sap_hana_preconfigure_reboot_after_update == true and sap_hana_preconfigure_register_reboot_required.rc == 1
@berndfinger berndfinger self-assigned this Oct 17, 2019
@piluxh
Copy link

piluxh commented Apr 10, 2020

Currently getting this error, so I would appreciate this change!

FAILED! => {"reason": "conflicting action statements: shell, async\n\nThe error appears to be in '/home/hpilmeyer/.ansible/roles/sap-hana-preconfigure/tasks/RedHat/installation.yml': line 85, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n # inspired by https://support.ansible.com/hc/en-us/articles/201958037-Reboot-a-server-and-wait-for-it-to-come-back\n - name: restart machine if required\n ^ here\n"}

@berndfinger
Copy link
Collaborator

I plan to use the same mechanism as in:
linux-system-roles/sap-preconfigure#69: The role should warn if a reboot is required after running yum update
linux-system-roles/sap-preconfigure#70: The role should be able to warn if a reboot is required after selinux state change

@berndfinger
Copy link
Collaborator

As we do not want to reboot in the role itself, I am closing this issue. Thanks for your efforts anyway!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants