jpmat296.win_pending_reboot
Ansible 角色: jpmat296.win_pending_reboot
这个角色使用 PowerShell 模块 PendingReboot 来检查并重启 Windows 主机,如果有待重启的情况。
待重启的原因默认会通过打印 PendingReboot
模块提供的详细信息来解释。
需求
这个角色会使用 win_psmodule
模块来处理 PendingReboot
的安装。win_psmodule
的要求必须被遵循,包括将 PowerShell 升级到最新版本。详细信息见此处:
https://docs.ansible.com/ansible/latest/collections/community/windows/win_psmodule_module.html#id3
满足这些要求的最简单方法是使用我的角色 jpmat296.upgrade_powershell。请参见下面的 剧本示例。
角色变量
# 当为'true'时,Ansible 执行日志包含待重启的原因
win_pending_reboot_explain: true
解释示例
当变量 win_pending_reboot_explain
设置为 true
(默认值)时,角色会在 Ansible 日志中写入待重启的原因。以下是一个示例:
依赖
没有依赖。使用角色 jpmat296.upgrade_powershell
是可选的。
示例剧本
以下是一个先升级 PowerShell 然后检查待重启的示例。两者都是幂等的。如果 PowerShell 已经升级且没有待重启,则不会执行任何操作。
- hosts: servers
tasks:
- name: 升级 PowerShell 和 Windows 管理框架到 5.1
import_role:
name: jpmat296.upgrade_powershell
- name: 如果有待重启,则重启
import_role:
name: jpmat296.win_pending_reboot
许可证
BSD
作者信息
这个角色是由 Jean-Pierre Matsumoto 在 2020 年底创建的。
关于项目
Reboot Windows host if reboot is pending. Root cause of pending reboot is explained.
安装
ansible-galaxy install jpmat296.win_pending_reboot
许可证
Unknown
下载
512