win_reboot - Fix rc validation when using psrp and add extra docs - 2.7 (#53718)
* win_reboot - Fix rc validation when using psrp and add extra docs (#53711) * win_reboot - Fix rc validation when using psrp and add extra docs * Revert boot time command and fix docs (cherry picked from commit3d23e47c53
) * win_reboot - fix broken tests after recent commit (#53722) (cherry picked from commitd9795bad98
)
This commit is contained in:
parent
f7a1911758
commit
4840952f3d
4 changed files with 9 additions and 3 deletions
2
changelogs/fragments/win_reboot-psrp.yaml
Normal file
2
changelogs/fragments/win_reboot-psrp.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- win_reboot - Fix reboot command validation failure when running under the psrp connection plugin
|
|
@ -61,6 +61,9 @@ options:
|
|||
notes:
|
||||
- If a shutdown was already scheduled on the system, C(win_reboot) will abort the scheduled shutdown and enforce its own shutdown.
|
||||
- For non-Windows targets, use the M(reboot) module instead.
|
||||
- The connection user must have the C(SeRemoteShutdownPrivilege) privilege enabled, see
|
||||
U(https://docs.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/force-shutdown-from-a-remote-system)
|
||||
for more information.
|
||||
author:
|
||||
- Matt Davis (@nitzmahone)
|
||||
'''
|
||||
|
|
|
@ -52,7 +52,7 @@ class ActionModule(RebootActionModule, ActionBase):
|
|||
def perform_reboot(self, task_vars, distribution):
|
||||
shutdown_command = self.get_shutdown_command(task_vars, distribution)
|
||||
shutdown_command_args = self.get_shutdown_command_args(distribution)
|
||||
reboot_command = '{0} {1}'.format(shutdown_command, shutdown_command_args)
|
||||
reboot_command = self._connection._shell._encode_script('{0} {1}'.format(shutdown_command, shutdown_command_args))
|
||||
|
||||
display.vvv("{action}: rebooting server...".format(action=self._task.action))
|
||||
display.debug("{action}: distribution: {dist}".format(action=self._task.action, dist=distribution))
|
||||
|
@ -69,7 +69,8 @@ class ActionModule(RebootActionModule, ActionBase):
|
|||
display.warning('A scheduled reboot was pre-empted by Ansible.')
|
||||
|
||||
# Try to abort (this may fail if it was already aborted)
|
||||
result1 = self._low_level_execute_command('shutdown /a', sudoable=self.DEFAULT_SUDOABLE)
|
||||
result1 = self._low_level_execute_command(self._connection._shell._encode_script('shutdown /a'),
|
||||
sudoable=self.DEFAULT_SUDOABLE)
|
||||
|
||||
# Initiate reboot again
|
||||
result2 = self._low_level_execute_command(reboot_command, sudoable=self.DEFAULT_SUDOABLE)
|
||||
|
|
|
@ -78,7 +78,7 @@
|
|||
ansible_password: '{{standard_pass}}'
|
||||
ansible_winrm_transport: ntlm
|
||||
register: fail_shutdown
|
||||
failed_when: "fail_shutdown.msg != 'Reboot command failed, error was: Access is denied.(5)'"
|
||||
failed_when: "'Reboot command failed, error was: Access is denied.(5)' not in fail_shutdown.msg"
|
||||
|
||||
always:
|
||||
- name: set the original SDDL to the WinRM listener
|
||||
|
|
Loading…
Reference in a new issue