mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 13:52:54 +00:00
Merge branch 'win_reboot-fix' of git://github.com/dagwieers/ansible into HEAD
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user