Hi folks,
Almost for as long as this thread exists, I've been following it from a far and thinking about ways to use Ansible with Windows.
Steve Irvine has put forth some DevOps PowerShell code. I think using the built-in system is probably a good idea.
But how can you call that from a Linux/Unix box with python/Ansible if you need/want it ?
The problem is how do you do what Michael DeHaan mentioned about not requiring to install anything on the target machine.
Well, in the Windows world there is this tool called PsExec from System Internals (a company aquired by Microsoft):
http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx
Here is a description of how it works:
"PsExec allows redirects of the input and output of a remotely started executable through the use of SMB and the hidden $ADMIN share on the remote system. With this share, PsExec uses the Windows Service control Manager API to start the PsExecsvc service on the remote system which creates a named pipe that PsExec communicates with. This named pipe is what allows for input/output redirection back to the system that launched PsExec."
The good thing about PsExec is it doesn't need any changes on the target Windows machine, you can connect to it with a default install. And the parts it depends on is usually not disabled. You only need some username/password combination (maybe it also possible to use some password-less Kerberos protocol for authentication I don't know).
There is only the firewall on a default install that could get in the way, but if the Windows-machine is part of a Windows-domain and you are on the same network there are no firewall settings to change. it just works.
Turns out there is a Python-project that use pcap to create, send and receive packets of certain protocols, including SMB, called impacket.
And they include a PsExec equivalant:
https://code.google.com/p/impacket/source/browse/trunk/examples/psexec.py
And I just did a quick test and you can use it on your Debian box to run a command on a Windows 2012 machine.
I've use PsExec with Windows before, I believe it also works with Windows 2008 and even Windows 2003.
The packages for impacket in the Debian and Ubuntu stable releases are to old though.
You'll need to download the release from the impacket site.
The other Python packages it depends on can be used from the stable release:
python-crypto
python-pcapy
Hope this is helpful somehow.
Have a nice day,
Leen.