ansible.builtin.win_reboot (v2.5.12) — module

Reboot a windows machine

| "added in version" 2.1 of ansible.builtin"

Authors: Matt Davis (@nitzmahone)

stableinterface | supported by core

Install Ansible via pip

Install with pip install ansible==2.5.12

Description

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

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Unconditionally reboot the machine with all defaults
- win_reboot:
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Apply updates and reboot if necessary
- win_updates:
  register: update_result
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- win_reboot:
  when: update_result.reboot_required
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Reboot a slow machine that might have lots of updates to apply
- win_reboot:
    reboot_timeout: 3600

Inputs

    
msg:
    default: Reboot initiated by Ansible
    description:
    - Message to display to users

test_command:
    default: whoami
    description:
    - Command to expect success for to determine the machine is ready for management

reboot_timeout:
    aliases:
    - reboot_timeout_sec
    default: 600
    description:
    - 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 network appearance and test command
      success (so maximum clock time is actually twice this value)

connect_timeout:
    aliases:
    - connect_timeout_sec
    default: 5
    description:
    - Maximum seconds to wait for a single successful TCP connection to the WinRM endpoint
      before trying again

pre_reboot_delay:
    aliases:
    - pre_reboot_delay_sec
    default: 2
    description:
    - Seconds for shutdown to wait before requesting reboot

shutdown_timeout:
    aliases:
    - shutdown_timeout_sec
    default: 600
    description:
    - 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

post_reboot_delay:
    aliases:
    - post_reboot_delay_sec
    default: 0
    description:
    - Seconds to wait after the reboot was successful and the connection was re-established
    - This is useful if you want wait for something to settle despite your connection
      already working
    version_added: '2.4'
    version_added_collection: ansible.builtin

Outputs

elapsed:
  description: The number of seconds that elapsed waiting for the system to be rebooted.
  returned: always
  sample: 23
  type: int
rebooted:
  description: true if the machine was rebooted
  returned: always
  sample: true
  type: boolean