win_reboot – Reboot a windows machine

From Get docs
Ansible/docs/2.7/modules/win reboot module


win_reboot – Reboot a windows machine

New in version 2.1.


Synopsis

  • Reboot a Windows machine, wait for it to go down, come back up, and respond to commands.

Parameters

Parameter Choices/Defaults Comments

connect_timeout

integer

Default:

5

Maximum seconds to wait for a single successful TCP connection to the WinRM endpoint before trying again


aliases: connect_timeout_sec

msg

-

Default:

"Reboot initiated by Ansible"

Message to display to users

post_reboot_delay

integer

added in 2.4

Default:

0

Seconds to wait after the reboot command was successful before attempting to validate the system rebooted successfully.

This is useful if you want wait for something to settle despite your connection already working.


aliases: post_reboot_delay_sec

pre_reboot_delay

integer

Default:

2

Seconds to wait before reboot. Passed as a parameter to the reboot command.


aliases: pre_reboot_delay_sec

reboot_timeout

integer

Default:

600

Maximum seconds to wait for machine to re-appear on the network and respond to a test command.

This timeout is evaluated separately for both reboot verification and test command success so maximum clock time is actually twice this value.


aliases: reboot_timeout_sec

shutdown_timeout

integer

Default:

600

Maximum seconds to wait for shutdown to occur

Increase this timeout for very slow hardware, large update applications, etc

This option has been removed since Ansible 2.5 as the win_reboot behavior has changed


aliases: shutdown_timeout_sec

test_command

-

Default:

"whoami"

Command to expect success for to determine the machine is ready for management



Notes

Note


Examples

# Unconditionally reboot the machine with all defaults
- win_reboot:

# Apply updates and reboot if necessary
- win_updates:
  register: update_result
- win_reboot:
  when: update_result.reboot_required

# Reboot a slow machine that might have lots of updates to apply
- win_reboot:
    reboot_timeout: 3600

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key Returned Description

elapsed

integer

always

The number of seconds that elapsed waiting for the system to be rebooted.


Sample:

23

rebooted

boolean

always

true if the machine was rebooted


Sample:

True




Status

Red Hat Support

More information about Red Hat’s support of this module is available from this Red Hat Knowledge Base article.

Authors

  • Matt Davis (@nitzmahone)

Hint

If you notice any issues in this documentation you can edit this document to improve it.


© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.7/modules/win_reboot_module.html