2016-07-08 143 views
3

我一直坚持使用Ansible窗口模块。我只是尝试ping machine.But我得到 '连接超时'在Ansible中,如何连接到Windows主机?

承载Windows

[windows] 
192.168.1.13 

group_vars/windows.yaml

ansible_user: raja 
ansible_password: myPassword 
ansible_port: 5986 
ansible_connection: winrm 
ansible_winrm_server_cert_validation: ignore 

,虽然我跑:ansible windows -vvv -i hosts -m win_ping

Using /etc/ansible/ansible.cfg as config file 
<192.168.1.13> ESTABLISH WINRM CONNECTION FOR USER: raja on PORT 5986 TO 192.168.1.13 
192.168.1.13 | UNREACHABLE! => { 
"changed": false, 
"msg": "ssl: HTTPSConnectionPool(host='192.168.1.13', port=5986): Max retries exceeded with url: /wsman (Caused by ConnectTimeoutError(<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7fcb12024a90>, 'Connection to 192.168.1.13 timed out. (connect timeout=30)'))", 
"unreachable": true 
} 

但是我可以ping通该Windows机器使用ping 192.168.1.13

回答

9

您需要准备Windows PowerShell远程管理的机器,否则ansible将无法连接到它。对于大多数要使用的功能,至少需要PowerShell 3.0 installed(仅在Windows 7 SP1或Windows Server 2008 SP1及更高版本中受支持),并且还运行this script,这不仅可以启用WinRM,还可以安装一些必要的证书连接工作。

一旦你donwload的ConfigureRemotingForAnsible.ps1文件从命令行下面的命令应该做的工作:

powershell.exe - 文件ConfigureRemotingForAnsible.ps1

+0

在某些时候,它可能是有用的使用版本化的链接,例如https://github.com/ansible/ansible/blob/c99c3b2b5d396b2cc1d25ad9aa6816aa922ffbc7/examples/scripts/ConfigureRemotingForAnsible.ps1。除此之外,我想知道,Ansible是否会自动运行此脚本?人们通常使用Ansible(或其他基于WinRM的工具)来调用这个脚本吗? – blong

相关问题