afisher@ubuntu:~/Projects/build-utils/ansible-playbooks$ ansible windows -i inventory.yml -m win_ping -vvvv
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
[WARNING]: ansible_winrm_cert_validation unsupported by pywinrm (is an up-to-date version of pywinrm installed?)
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/core/windows/win_ping.ps1
<edprjenslave03.DOMAIN.COM> ESTABLISH WINRM CONNECTION FOR USER: afi...@DOMAIN.COM on PORT 5985 TO edprjenslave03.DOMAIN.COM
edprjenslave03.DOMAIN.COM | UNREACHABLE! => {
"changed": false,
"msg": "kerberos: (u'http', u'Bad HTTP response returned from server. Code 500'), plaintext: the specified credentials were rejected by the server",
"unreachable": true
}
Ticket cache: FILE:/tmp/krb5cc_1000
Default principal: afi...@DOMAIN.COM
Valid starting Expires Service principal
05/02/2017 09:23:47 05/02/2017 19:23:47 krbtgt/DOMAI...@DOMAIN.COM
renew until 05/03/2017 09:23:41
05/02/2017 09:49:54 05/02/2017 19:23:47 HTTP/edprjenslave03.domain.com@
renew until 05/03/2017 09:23:41
05/02/2017 09:49:54 05/02/2017 19:23:47 HTTP/edprjenslave...@DOMAIN.COM
renew until 05/03/2017 09:23:41
afisher@ubuntu:~/Projects/build-utils/ansible-playbooks$ sudo -H pip install --upgrade pywinrm
Requirement already up-to-date: pywinrm in /usr/local/lib/python2.7/dist-packages
Requirement already up-to-date: xmltodict in /usr/local/lib/python2.7/dist-packages (from pywinrm)
Requirement already up-to-date: requests-ntlm>=0.3.0 in /usr/local/lib/python2.7/dist-packages (from pywinrm)
Requirement already up-to-date: six in /usr/lib/python2.7/dist-packages (from pywinrm)
Requirement already up-to-date: requests>=2.9.1 in /usr/local/lib/python2.7/dist-packages (from pywinrm)
Requirement already up-to-date: ntlm-auth>=1.0.2 in /usr/local/lib/python2.7/dist-packages (from requests-ntlm>=0.3.0->pywinrm)
---
[windows]
edprjenslave03.DOMAIN.COM
---
ansible_user: afi...@DOMAIN.COM
ansible_password: the_pass
ansible_port: 5985
ansible_connection: winrm
ansible_winrm_cert_validation: ignore
The first thing is that pywinrm doesn't play nice wth HTTP end points unless you disable the majority of the security configurations like AllowUnencrypted=true so try and setup a HTTPS endpoint and use that. The script here https://github.com/ansible/ansible/blob/devel/examples/scripts/ConfigureRemotingForAnsible.ps1 will set one up for you with a self signed certificate which is good to use for testing.
There are some particular WinRM auth settings that are not fully supported as welll currently like CbtHardeningLevel set to strict with Kerberos. If you run "winrm get winrm/config/service/auth" you can see what level it is currently set at. You can also see if Kerberos auth is actually enabled. If your workplace mandates this need to be set to Strict for security purposes your only options would be to use NTLM or CredSSP which currently supports CBT.
Have a go with these 2 thing ad let us know if you still have any issues.
Also, use ansible 2.3 as it has built in support for acquiring Kerberos (active directory) tickets. You still need to configure your krb5.conf and install the Kerberos libs as listed in the wndows setup documentation of course.
Hole this helps,
Jon
PS C:\Users\afisher\Documents> C:\Users\afisher\Documents\ConfigureRemotingForAnsible.ps1 -Verbose
VERBOSE: Verifying WinRM service.
VERBOSE: PS Remoting is already enabled.
VERBOSE: SSL listener is already active.
VERBOSE: Basic auth is already enabled.
VERBOSE: Firewall rule already exists to allow WinRM HTTPS.
VERBOSE: HTTP: Enabled | HTTPS: Enabled
VERBOSE: PS Remoting has been successfully configured for Ansible.
PS C:\Users\Administrator> winrm get winrm/config/service
Service
RootSDDL = O:NSG:BAD:P(A;;GA;;;BA)(A;;GR;;;IU)S:P(AU;FA;GA;;;WD)(AU;SA;GXGW;;;WD)
MaxConcurrentOperations = 4294967295
MaxConcurrentOperationsPerUser = 1500
EnumerationTimeoutms = 240000
MaxConnections = 300
MaxPacketRetrievalTimeSeconds = 120
AllowUnencrypted = false
Auth
Basic = true
Kerberos = true
Negotiate = true
Certificate = false
CredSSP = false
CbtHardeningLevel = Relaxed
DefaultPorts
HTTP = 5985
HTTPS = 5986
IPv4Filter = *
IPv6Filter = *
EnableCompatibilityHttpListener = false
EnableCompatibilityHttpsListener = false
CertificateThumbprint
AllowRemoteAccess = true
winrm set winrm/config/service '@{AllowUnencrypted="true"}'Some other things to try
- use a real powershell host and connect with those credentials, will verify if the account is valid and has enough permissions
- use pywinrm direct and manually get a Kerberos ticket using kinit, will see if Ansible is getting the tickets correctly
- try using NTLM as a test instead, will see if the problem is in the Kerberos auth somewhere
- scan the Windows security event logs and try and find the reason it is rejecting each request
Hi All--I'm running into an issue connecting from an Ubuntu 16.04 system to a Windows 2012 Server on a domain:afisher@ubuntu:~/Projects/build-utils/ansible-playbooks$ ansible windows -i inventory.yml -m win_ping -vvvv
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
[WARNING]: ansible_winrm_cert_validation unsupported by pywinrm (is an up-to-date version of pywinrm installed?)
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/core/windows/win_ping.ps1
<edprjenslave03.DOMAIN.COM> ESTABLISH WINRM CONNECTION FOR USER: afi...@DOMAIN.COM on PORT 5985 TO edprjenslave03.DOMAIN.COM
edprjenslave03.DOMAIN.COM | UNREACHABLE! => {
"changed": false,
"msg": "kerberos: (u'http', u'Bad HTTP response returned from server. Code 500'), plaintext: the specified credentials were rejected by the server",
"unreachable": true
}At first it was just refusing without the kerberos part of the error. Realized I didn't have Kerberos installed. Remedied that:
Ticket cache: FILE:/tmp/krb5cc_1000
Default principal: afi...@DOMAIN.COM
Valid starting Expires Service principal
05/02/2017 09:23:47 05/02/2017 19:23:47 krbtgt/DOMAI...@DOMAIN.COM
renew until 05/03/2017 09:23:41
05/02/2017 09:49:54 05/02/2017 19:23:47 HTTP/edprjenslave03.domain.com@
renew until 05/03/2017 09:23:41
05/02/2017 09:49:54 05/02/2017 19:23:47 HTTP/edprjenslave03.domain.c...@DOMAIN.COM
renew until 05/03/2017 09:23:41
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/621ec7c6-433d-45af-a92d-4b4ef8f5d07e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/E285C771-3ACF-42DB-A160-A766671AD617%40gmail.com.