I've been attempting to write playbooks that need to interact with Active Directory, I see now that a few official playbooks will be released in 2.4 that can manage AD groups and users which is sweet. My issue is that the only way I can run our current playbooks is by using a Domain Admin account to run them. To be more secure I don't want my Ansible account to be a DA. WinRM works fine for DA's from Ansible, however when I use an account that isn't a DA I get this error in response.
Loading callback plugin minimal of type stdout, v2.0 from /usr/lib/python2.7/site-packages/ansible/plugins/callback/__init__.pyc
META: ran handlers
<DChostname> ESTABLISH WINRM CONNECTION FOR USER: nonD...@domain.COM on PORT 5986 TO <DChostname>
creating Kerberos CC at /tmp/tmpb3JbPz
calling kinit for principal nonD...@domain.COM
kinit succeeded for principal nonD...@domain.COM
<DChostname> WINRM CONNECTION ERROR: (u'http', u'Bad HTTP response returned from server. Code 500')
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/ansible/plugins/connection/winrm.py", line 214, in _winrm_connect
self.shell_id = protocol.open_shell(codepage=65001) # UTF-8
File "/usr/lib/python2.7/site-packages/winrm/protocol.py", line 132, in open_shell
res = self.send_message(xmltodict.unparse(req))
File "/usr/lib/python2.7/site-packages/winrm/protocol.py", line 207, in send_message
return self.transport.send_message(message)
File "/usr/lib/python2.7/site-packages/winrm/transport.py", line 191, in send_message
raise WinRMTransportError('http', error_message)
WinRMTransportError: (u'http', u'Bad HTTP response returned from server. Code 500')
<DChostname> WINRM CONNECTION ERROR: the specified credentials were rejected by the server
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/ansible/plugins/connection/winrm.py", line 214, in _winrm_connect
self.shell_id = protocol.open_shell(codepage=65001) # UTF-8
File "/usr/lib/python2.7/site-packages/winrm/protocol.py", line 132, in open_shell
res = self.send_message(xmltodict.unparse(req))
File "/usr/lib/python2.7/site-packages/winrm/protocol.py", line 207, in send_message
return self.transport.send_message(message)
File "/usr/lib/python2.7/site-packages/winrm/transport.py", line 179, in send_message
raise InvalidCredentialsError("the specified credentials were rejected by the server")
InvalidCredentialsError: the specified credentials were rejected by the server
The analytic logs on the DC show this event after the nonDAacct gets authenticated via kerberos:
An error was encountered while processing an operation.
When I connect to a DC from my desktop using the PowerShell command "enter-pssession <DC name> -credentials <nonDAacct>" I can access the DC and manipulate AD objects just fine. It is only using Ansible that I cannot connect properly.
Does anyone else run commands that need to interact with AD objects as an account that is not a DA? Any other suggestions for things to try and or change? If anything isn't clear or I need to add some more detail please let me know and I'll be happy to share.