Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Tip

请在使用站内资源的同时不要恶意进行爬取或倒链等行为,感谢支持!

Note

相关文档:

UI Button
colorblue
newWindowtrue
sizesmall
displayblock
iconlink
title链接

Info
iconfalse

Table of Contents

Ansible Windows

Ansible 使用 Windows 需要开启一系列的配置,如下:

安装

需要安装以下组件。Windows 7 环境或 Server 2008 。

Microsoft .NET Framework 4.5

下载地址:

UI Button
colorblue
newWindowtrue
sizesmall
iconlink
titleMicrosoft .NET Framework 4.5
urlhttps://download.microsoft.com/download/B/A/4/BA4A7E71-2906-4B2D-A0E1-80CF16844F5F/dotNetFx45_Full_setup.exe

Powershell

需要安装 powershell 4.0,默认是 Powershell 2.0,下载地址:

UI Button
colorblue
newWindowtrue
sizesmall
iconlink
titlePowerShell 4.0
urlhttps://download.microsoft.com/download/3/D/6/3D61D262-8549-4769-A660-230B67E15B25/Windows6.1-KB2819745-x64-MultiPkg.msu

升级完可执行命令获取当前版本:


Winrm

配置 Winrm 。通过 PowerShell 查看当前策略:

Code Block
languagebash
$ get-executionpolicy

如图:

修改策略:

Code Block
languagebash
$ set-executionpolicy remotesigned

如图:

启动服务:

Code Block
languagebash
$ winrm quickconfig

如图:

网络配置有问题,可修改为:

重新执行:

查看服务监听状态:

Code Block
languagebash
$ winrm enumerate winrm/config/listener

如图:

启用远程认证:

Code Block
languagebash
$ winrm set winrm/config/service/auth '@{Basic="true"}'
$ winrm set winrm/config/service '@{AllowUnencrypted="true"}'

如图:

防火墙

新建防火墙规则:

信任端口:

信任 5985 端口:

填写配置,点击完成:

Python(可忽略)

安装 3.7.2 版本或者其他:

UI Button
colorblue
newWindowtrue
sizesmall
iconlink
titlePython 3.7.2 install
urlhttps://www.python.org/ftp/python/3.7.2/python-3.7.2-amd64.exe
,下载后傻瓜式安装。我的安装路径为:

Code Block
languagebash
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64

设置环境变量:

设置时用分号 ";" 分隔。测试如下:

Ansible 配置

在 Ansible 上配置添加 host,在 /etc/ansible/hosts 中添加如下配置:

Code Block
languagebash
[windows]
10.31.129.16 ansible_ssh_user="Administrator" ansible_ssh_pass="1234554321" ansible_ssh_port=5985 ansible_connection="winrm" ansible_winrm_server_cert_validation=ignore

然后执行测试命令:

Code Block
languagebash
$ ansible windows -m win_ping

执行结果为:

文档创建于 最后一次更新于  , 文档当前的状态 

Status
colourGreen
title正式版
 , 当前编写页面的版本 
Status
colourBlue
titlev1.3.1
 。