Linux下的ansible管理win10

设置Windows远端管理(WS-Management,WinRM)
winrm service 默认都是未启用的状态,先查看状态;如无返回信息,则是没有启动;

winrm enumerate winrm/config/listener
#
#
#

#
#
#
针对winrm service 进行基础配置:

winrm quickconfig
#
#

#
#

#

#

#
#

#
#

#
#
需要把需要ansible管理的window机器调成专有网络
#
#


#
#
#

查看winrm service listener:

winrm e winrm/config/listener

#
#
#


#
#

#
#
#
执行后查看window上5985端口是否开启
#
#

为winrm service 配置auth:

winrm set winrm/config/service/auth @{Basic="true"}
#
#
#

#
#
#

为winrm service 配置加密方式为允许非加密:

winrm set winrm/config/service @{AllowUnencrypted="true"}
#
#
#

#
#

福利
#
#

好了,远程Windows主机配置到此结束,我们验证配置的是否有问题。

配置ansible server段host配置

#
#

#
#
192.168.0.57 ansible_ssh_user=dell ansible_ssh_pass="xxxxx" ansible_ssh_port=5985 ansible_connection="winrm"
#
#
#
#
Windows下可用模块测试
win_ping —Windows系统下的ping模块,常用来测试主机是否存活
ansible host -m win_ping

#
#

#
#

#
#
TASK [setup] ***
fatal: [192.168.0.57]: UNREACHABLE! => {"changed": false, "msg": "plaintext: HTTPConnectionPool(host='192.168.0.57', port=5985): Max retries exceeded with url: /wsman (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused',))", "unreachable": true}

#
当出现这种情况说明你的window服务器winrm没有开启
#
#

#
#
fatal: [192.168.0.57]: UNREACHABLE! => {
"changed": false,
"msg": "plaintext: the specified credentials were rejected by the server",
"unreachable": true
}
#
#
当出现这种情况是你网络模式不是专有网络或者window用户权限的问题
#
#

楼镇图

转载于:https://blog.51cto.com/13386520/2340266

你可能感兴趣的:(Linux下的ansible管理win10)