jpmat296.win_pending_reboot

Ansible role: jpmat296.win_pending_reboot

Ansible Galaxy CI

This role uses the PowerShell module PendingReboot to reboot Windows computers if a reboot is necessary.

The reason for a pending reboot is explained by the PendingReboot module.

Requirements

This role automatically installs the PendingReboot module using the win_psmodule module. Make sure to meet the requirements for win_psmodule, including having an updated version of PowerShell. You can find more information here.

To easily meet these requirements, you can use my role jpmat296.upgrade_powershell. Check the playbook example below.

Role Variables

# This variable makes the execution log show the cause of the pending reboot when set to 'true'
win_pending_reboot_explain: true

Example Explanation

When the variable win_pending_reboot_explain is set to true (which is the default), the role logs the reason for the pending reboot in Ansible. Here’s an example:

pending reboot ansible trace

Dependencies

No dependencies needed. The use of the role jpmat296.upgrade_powershell is optional.

Example Playbook

Here’s an example of how to check for a pending reboot after upgrading PowerShell. Both tasks are idempotent, meaning they will do nothing if PowerShell is already upgraded and no reboot is pending.

- hosts: servers
  tasks:
    - name: Upgrade PowerShell & Windows Management Framework to 5.1
      import_role:
        name: jpmat296.upgrade_powershell
    - name: Reboot if reboot is pending
      import_role:
        name: jpmat296.win_pending_reboot

License

BSD

Author Information

This role was created in late 2020 by Jean-Pierre Matsumoto.

Informazioni sul progetto

Reboot Windows host if reboot is pending. Root cause of pending reboot is explained.

Installa
ansible-galaxy install jpmat296.win_pending_reboot
Licenza
Unknown
Download
512
Proprietario