ansible管理win10
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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(‘<requests.packages.urllib3.connection.HTTPConnection object at 0x341fa90>: 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用户权限的问题
#
#
楼镇图
以上是关于ansible管理win10的主要内容,如果未能解决你的问题,请参考以下文章
Win10下从零搭建Linux+Ansible+K8S 学习环境笔记(1*Master/controller+3*Node)
Win10下从零搭建Linux+Ansible+K8S 学习环境笔记(1*Master/controller+3*Node)