|
|
|
@ -83,9 +83,21 @@ class ActionModule(ActionBase):
|
|
|
|
|
|
|
|
|
|
result = super(ActionModule, self).run(tmp, task_vars)
|
|
|
|
|
|
|
|
|
|
# initiate reboot
|
|
|
|
|
# Initiate reboot
|
|
|
|
|
(rc, stdout, stderr) = self._connection.exec_command('shutdown /r /t %d /c "%s"' % (pre_reboot_delay_sec, msg))
|
|
|
|
|
|
|
|
|
|
# Test for "A system shutdown has already been scheduled. (1190)" and handle it gracefully
|
|
|
|
|
if rc == 1190:
|
|
|
|
|
result['warnings'] = ( 'A scheduled reboot was pre-empted by Ansible.' )
|
|
|
|
|
|
|
|
|
|
# Try to abort (this may fail if it was already aborted)
|
|
|
|
|
(rc, stdout1, stderr1) = self._connection.exec_command('shutdown /a')
|
|
|
|
|
|
|
|
|
|
# Initiate reboot again
|
|
|
|
|
(rc, stdout2, stderr2) = self._connection.exec_command('shutdown /r /t %d' % pre_reboot_delay_sec)
|
|
|
|
|
stdout += stdout1 + stdout2
|
|
|
|
|
stderr += stderr1 + stderr2
|
|
|
|
|
|
|
|
|
|
if rc != 0:
|
|
|
|
|
result['failed'] = True
|
|
|
|
|
result['rebooted'] = False
|
|
|
|
|