Hello,
I try to setup a simple Ansible inventory for Windows server using basic authentication. Both my machines are in Azure. Windows server is not in domain and has a user who is a member in Administrators and Remote Management groups.
HTTPS between machines work:
$ nc -z -w1 test1.eastus.cloudapp.azure.com 5986;echo $?
0
However, when I try a simple ping command it fails:
$ ansible windows -i hosts -m win_ping -vvvvv
Using /etc/ansible/ansible.cfg as config file
Loading callback plugin minimal of type stdout, v2.0 from /usr/lib/python2.7/dist-packages/ansible/plugins/callback/init.pyc
META: ran handlers
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/windows/win_ping.ps1
<vm-server1.eastus.cloudapp.azure.com> ESTABLISH WINRM CONNECTION FOR USER: .\medcon on PORT 5986 TO vm-server1.eastus.cloudapp.azure.com
<vm-server1.eastus.cloudapp.azure.com> WINRM CONNECT: transport=ssl endpoint=https://vm-server1.eastus.cloudapp.azure.com:5986/wsman
<vm-server1.eastus.cloudapp.azure.com> WINRM CONNECTION ERROR: the specified credentials were rejected by the server
Traceback (most recent call last):
File “/usr/lib/python2.7/dist-packages/ansible/plugins/connection/winrm.py”, line 214, in _winrm_connect
self.shell_id = protocol.open_shell(codepage=65001) # UTF-8
File “/usr/local/lib/python2.7/dist-packages/winrm/protocol.py”, line 132, in open_shell
res = self.send_message(xmltodict.unparse(req))
File “/usr/local/lib/python2.7/dist-packages/winrm/protocol.py”, line 207, in send_message
return self.transport.send_message(message)
File “/usr/local/lib/python2.7/dist-packages/winrm/transport.py”, line 198, in send_message
raise InvalidCredentialsError(“the specified credentials were rejected by the server”)
InvalidCredentialsError: the specified credentials were rejected by the server
vm-server1.eastus.cloudapp.azure.com | UNREACHABLE! => {
“changed”: false,
“msg”: “ssl: the specified credentials were rejected by the server”,
“unreachable”: true
}
I looked into a lot of posts in this group, github and on inet and found nothing that could help.
My inventory (hosts) file:
$ cat hosts
[windows]
test1.eastus.cloudapp.azure.com
[windows:vars]
ansible_user=.\test
ansible_password=secret_password
ansible_port=5986
ansible_connection=winrm
ansible_winrm_server_cert_validation=ignore
Needless to say that the credentials work when I RDP to the machine.
Other relevant information about machines
Ansible control machine:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.2 LTS
Release: 16.04
Codename: xenial
$ ansible --version
ansible 2.3.0.0
config file = /etc/ansible/ansible.cfg
configured module search path = Default w/o overrides
python version = 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609]
Windows server machine: