2016-07-08 144 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

相關問題