ansible控制windows机器

windows上准备:
我的环境是windows server 2012,上面的powershell和winrm都是现成可用的。简单配置winrm即可:

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

上面如果没有执行,在ping的时候可能会报:the specified credentials were rejected by the server

ubuntu16.04上准备:
首先确保已经安装了ansible
如果是报错:winrm or requests is not installed: No module named winrm。则安装下面

apt install python-pip
pip install "pywinrm>=0.1.1"

如果报错:AttributeError: 'module' object has no attribute 'SSL_ST_INIT'

rm -rf /usr/lib/python2.7/dist-packages/OpenSSL
rm -rf /usr/lib/python2.7/dist-packages/pyOpenSSL-0.15.1.egg-info
sudo pip install pyopenssl

最后使用ansible ping一下看看,如果通了就说明是OK的。

标签: none

添加新评论