「Ansible」- 管理 Windows 主机

本笔记只记录管理 Windows 主机的通用设置流程,是对 Docs » User Guide » Windows Guides 手册的学习整理。

第一步、设置 Windows 主机

主机要求

Ansible can generally manage Windows versions under current and extended support from Microsoft. Ansible can manage desktop OSs including Windows 7, 8.1, and 10, and server OSs including Windows Server 2008, 2008 R2, 2012, 2012 R2, 2016, and 2019.

Ansible requires PowerShell 3.0 or newer and at least .NET 4.0 to be installed on the Windows host.

A WinRM listener should be created and activated. More details for this can be found below.

或者也可以使用 SSH 服务,但是官网也给出警告:Use this feature at your own risk! Using SSH with Windows is experimental, the implementation may make backwards incompatible changes in feature releases. The server side components can be unreliable depending on the version that is installed.

设置 WinRM 服务

官方推荐给出连接与管理 Windows 主机的方法,使用 WinRM 服务。

设置 SSH 服务(官方有警告)

虽然可以使用,但是官方警告存在版本兼容性问题,所以可靠性无法得到保证。

Windows Remote Management

本部分介绍使用 WinRM 连接并管理主机时,相关配置设置等内容。

第二步、使用 Ansible 管理 Windows 主机

本部分介绍如何使用 Ansible 及其 Modules 管理 Windows 主机。

Desired State Configuration(可选方案)

使用 Ansible 的 win_dsc 模块来调用 DSC 工具。

性能优化

优化处理 PowerShell 性能问题。

常见问题

在使用过程中可能会遇到的问题,以及某些常见问题。

参考文献

Docs » User Guide » Windows Guides