我在Linux(14.04)工作站上安裝了Ansible,Python(2.7.6),ansible(2.3.0),pywinrm(0.2.1)。我想用Ansible來配置我的Windows虛擬機。我在Azure中有一個Windows VM(Win2k12r2)。我已經打開了Azure網絡安全組中的所有端口,並且已經在Windows防火牆中爲WinRM打開了端口(5985和5986)。Ansible for Windows:無法通過WinRM訪問Windows機器
我還在我的Windows VM中運行了位於https://github.com/ansible/ansible/blob/devel/examples/scripts/ConfigureRemotingForAnsible.ps1的腳本,以確保WinRM已啓用。
我能夠將RDP放入Windows VM,所以我知道它的公共網絡接口正在工作。
作爲每ansible文檔(http://docs.ansible.com/ansible/intro_windows.html)我有一個清單文件清單/ TEST1
[windows]
<azure_ip_address>
和我有一個文件group_vars/windows.yml
ansible_user: <my_user_id>
ansible_password: <azure_vm_password>
ansible_port: 5986
ansible_connection: winrm
# The following is necessary for Python 2.7.9+ when using default WinRM self-signed certificates:
ansible_winrm_server_cert_validation: ignore
ansible_winrm_scheme: https
當我運行下面的命令:
ansible windows -i inventories/test1 -m win_ping --ask-vault-pass -vvvvv
我收到以下回復:
No config file found; using defaults
Vault password:
Loading callback plugin minimal of type stdout, v2.0 from /home/jgodse/ansible/lib/ansible/plugins/callback/__init__.pyc
Using module file /home/jgodse/ansible/lib/ansible/modules/core/windows/win_ping.ps1
<azure_vm_ip_address> ESTABLISH SSH CONNECTION FOR USER: None
<azure_vm_ip_address> SSH: ansible.cfg set ssh_args: (-C)(-o)(ControlMaster=auto)(-o)(ControlPersist=60s)
<azure_vm_ip_address> SSH: ansible_password/ansible_ssh_pass not set: (-o) (KbdInteractiveAuthentication=no)(-o)(PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey)(-o)(PasswordAuthentication=no)
<azure_vm_ip_address> SSH: ANSIBLE_TIMEOUT/timeout set: (-o)(ConnectTimeout=10)
<azure_vm_ip_address> SSH: PlayContext set ssh_common_args:()
<azure_vm_ip_address> SSH: PlayContext set ssh_extra_args:()
<azure_vm_ip_address> SSH: found only ControlPersist; added ControlPath: (-o)(ControlPath=/home/jgodse/.ansible/cp/ansible-ssh-%h-%p-%r)
<azure_vm_ip_address> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/home/jgodse/.ansible/cp/ansible-ssh-%h-%p-%r <azure_vm_ip_address> '/bin/sh -c '"'"'(umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1477490434.84-228998637685624 `" && echo ansible-tmp-1477490434.84-228998637685624="` echo $HOME/.ansible/tmp/ansible-tmp-1477490434.84-228998637685624 `") && sleep 0'"'"''
<azure_vm_ip_address> | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug1: Control socket \"/home/jgodse/.ansible/cp/ansible-ssh-<azure_vm_ip_address>-22-jgodse\" does not exist\r\ndebug2: ssh_connect: needpriv 0\r\ndebug1: Connecting to <azure_vm_ip_address> [<azure_vm_ip_address>] port 22.\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug1: connect to address <azure_vm_ip_address> port 22: Connection timed out\r\nssh: connect to host <azure_vm_ip_address> port 22: Connection timed out\r\n",
"unreachable": true
}
我試圖Telnet到本機如下:
$ telnet <azure_vm_ip_address> 5986
Trying <azure_vm_ip_address>...
Connected to <azure_vm_ip_address>.
Escape character is '^]'.
這告訴我,遠程登錄合作,5986,因此我的防火牆規則是確定。
我是否需要做一些事情來告訴Ansible,我正嘗試使用WinRM連接到Windows VM?或者我缺少一些東西來幫助我的Ansible工作站通過WinRM連接到我的Windows VM?
好吧,你根據你鏈接的文章配置窗口嗎? – 4c74356b41
是的。而且我知道,因爲Windows遠程管理(WS-Management)服務已啓動並正在運行。 –
嘗試psremote到它? – 4c74356b41