ansible / ansible.builtin / v2.9.27 / module / win_reboot Reboot a windows machine | "added in version" 2.1 of ansible.builtin" Authors: Matt Davis (@nitzmahone) stableinterface | supported by coreansible.builtin.win_reboot (v2.9.27) — module
pip
Install with pip install ansible==2.9.27
Reboot a Windows machine, wait for it to go down, come back up, and respond to commands.
For non-Windows targets, use the M(reboot) module instead.
- name: Reboot the machine with all defaults win_reboot:
- name: Reboot a slow machine that might have lots of updates to apply win_reboot: reboot_timeout: 3600
# Install a Windows feature and reboot if necessary - name: Install IIS Web-Server win_feature: name: Web-Server register: iis_install
- name: Reboot when Web-Server feature requires it win_reboot: when: iis_install.reboot_required
# One way to ensure the system is reliable, is to set WinRM to a delayed startup - name: Ensure WinRM starts when the system has settled and is ready to work reliably win_service: name: WinRM start_mode: delayed
# Additionally, you can add a delay before running the next task - name: Reboot a machine that takes time to settle after being booted win_reboot: post_reboot_delay: 120
# Or you can make win_reboot validate exactly what you need to work before running the next task - name: Validate that the netlogon service has started, before running the next task win_reboot: test_command: 'exit (Get-Service -Name Netlogon).Status -ne "Running"'
msg: default: Reboot initiated by Ansible description: - Message to display to users. type: str test_command: default: whoami description: - Command to expect success for to determine the machine is ready for management. type: str 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 reboot verification and test command success so maximum clock time is actually twice this value. type: int 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. type: int pre_reboot_delay: aliases: - pre_reboot_delay_sec default: 2 description: - Seconds to wait before reboot. Passed as a parameter to the reboot command. type: int 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. type: int post_reboot_delay: aliases: - post_reboot_delay_sec default: 0 description: - 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. type: int version_added: '2.4' version_added_collection: ansible.builtin
elapsed: description: The number of seconds that elapsed waiting for the system to be rebooted. returned: always sample: 23.2 type: float rebooted: description: True if the machine was rebooted. returned: always sample: true type: bool