ansible.windows.win_reboot_info module – Get reboot status information for a Windows host
Note
This module is part of the ansible.windows collection (version 3.7.0).
It is not included in ansible-core.
To check whether it is installed, run ansible-galaxy collection list.
To install it, use: ansible-galaxy collection install ansible.windows.
To use it in a playbook, specify: ansible.windows.win_reboot_info.
New in ansible.windows 3.8.0
Synopsis
Returns information about the last boot time and whether a reboot is pending on the target Windows host.
A pending reboot can be caused by Windows Update, Component Based Servicing, pending file rename operations, domain join operations, or Server Manager component changes.
See Also
See also
- ansible.windows.win_reboot
Reboot a windows machine.
Examples
- name: Get reboot info
ansible.windows.win_reboot_info:
register: reboot_info
- name: Reboot if required
ansible.windows.win_reboot:
when: reboot_info.reboot_required
- name: Display last boot time
ansible.builtin.debug:
msg: "Last boot: {{ reboot_info.last_reboot.time }}"
- name: Show who initiated the last reboot
ansible.builtin.debug:
msg: >-
Last reboot was initiated by {{ reboot_info.last_reboot.details.initiated_by }}
via {{ reboot_info.last_reboot.details.process }}
with comment: {{ reboot_info.last_reboot.details.comment }}
when: reboot_info.last_reboot.details is not none
- name: Show pending reboot sources
ansible.builtin.debug:
msg: "Pending reboot due to: {{ reboot_info.reboot_required_reasons | map(attribute='source') | list }}"
when: reboot_info.reboot_required
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
|---|---|
Information about the last system boot. Returned: always |
|
Details about the most recent shutdown or restart event from the Windows Event Log. This is gathered from Event ID 1074 in the System log. Will be Returned: success |
|
The comment or message provided when the reboot was initiated. Returned: success Sample: |
|
The time the shutdown event was logged as an ISO 8601 UTC timestamp. Returned: success Sample: |
|
The user account that initiated the reboot. Returned: success Sample: |
|
The process that triggered the reboot. Returned: success Sample: |
|
The reason category for the reboot. Returned: success Sample: |
|
The shutdown reason code associated with the reboot, as recorded in the event log. This is a 32-bit value combining the major reason, minor reason, and flag bits (for example the high bit indicates a planned shutdown). This is normally returned as an integer, but may fall back to the raw value from the event log if it could not be parsed as an integer. The Windows event viewer displays this value as a hexadecimal string (for example Returned: success Sample: |
|
The type of action, such as Returned: success Sample: |
|
The last boot time of the system as an ISO 8601 UTC timestamp. Returned: success Sample: |
|
The last boot time as a Unix epoch timestamp in seconds. Returned: success Sample: |
|
Whether the system has a pending reboot from any source. Returned: always Sample: |
|
A list of sources that require a reboot. Will be an empty list if no reboot is pending. Returned: always |
|
A human-readable description of why a reboot is pending. Returned: success Sample: |
|
The source that requires a reboot. Known sources are Returned: success Sample: |