Closed lilasquared closed 6 years ago
I'm not familiar with using Ansible to manage Windows machines but I have reviewed the article and it looks like I just need to add the pywinrm dependency to the image and it should work. I do not have a way to test the change to see if it works for your use case, but I will push the change and build a "latest" image tag. Would you be able to test it and make sure it works for your use case?
I will give it a shot!
Did it work for your use case?
Apologies for the delay - finally got some time to work on this.
I am getting this error when attempting to connect using kerbos
FAILED! => {"msg": "The installed version of WinRM does not support transport(s) [u'kerbos']"}
I wonder if these steps can be added to the docker file, and then the config file could be passed in?
https://docs.ansible.com/ansible/devel/user_guide/windows_winrm.html#installing-the-kerberos-library
it also could be that i just don't know what I am doing. Would it be possible to upgrade this image to use python 3 instead of 2? not sure if that will make a difference.
Thank you for the link. I have pushed an update to use kerberos deps.
As for the config, I believe you should be able to provide it via a mount (i.e. -v). For example, something like this should work:
docker run -it --rm -v $PWD:/tmp/playbook:Z -v $PWD/krb5.conf:/etc/krb5.conf:Z jmal98/ansiblecm site.yml -i inventory/hosts
thanks! I will give it another shot!
@jmal98 this worked successfully for me - thank you so much!
Edit: Apparently I am a liar. I got my playbook to work but not inside of the docker container. Here is the error I received.
The full traceback is:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/ansible/executor/task_executor.py", line 138, in run
res = self._execute()
File "/usr/lib/python2.7/site-packages/ansible/executor/task_executor.py", line 554, in _execute
result = self._handler.run(task_vars=variables)
File "/usr/lib/python2.7/site-packages/ansible/plugins/action/normal.py", line 46, in run
result = merge_hash(result, self._execute_module(task_vars=task_vars, wrap_async=wrap_async))
File "/usr/lib/python2.7/site-packages/ansible/plugins/action/__init__.py", line 795, in _execute_module
res = self._low_level_execute_command(cmd, sudoable=sudoable, in_data=in_data)
File "/usr/lib/python2.7/site-packages/ansible/plugins/action/__init__.py", line 902, in _low_level_execute_command
rc, stdout, stderr = self._connection.exec_command(cmd, in_data=in_data, sudoable=sudoable)
File "/usr/lib/python2.7/site-packages/ansible/plugins/connection/winrm.py", line 472, in exec_command
super(Connection, self).exec_command(cmd, in_data=in_data, sudoable=sudoable)
File "/usr/lib/python2.7/site-packages/ansible/plugins/connection/__init__.py", line 38, in wrapped
self._connect()
File "/usr/lib/python2.7/site-packages/ansible/plugins/connection/winrm.py", line 441, in _connect
self.protocol = self._winrm_connect()
File "/usr/lib/python2.7/site-packages/ansible/plugins/connection/winrm.py", line 334, in _winrm_connect
self._kerb_auth(self._winrm_user, self._winrm_pass)
File "/usr/lib/python2.7/site-packages/ansible/plugins/connection/winrm.py", line 299, in _kerb_auth
env=krb5env)
File "/usr/lib/python2.7/subprocess.py", line 390, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1025, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
fatal: [wwa00923.deluxe.com]: FAILED! => {
"msg": "Unexpected failure during module execution.",
"stdout": ""
}
I pushed an update to include more of the kerberos dependencies. Can you give it another try?
Also, does the playbook you're using delegate any tasks to the machine running the playbook?
I will as soon as I can. As for the playbook It is using the windows modules to connect to a remote windows server 2016 to perform the tasks. Does that answer your question?
Yes, it does. Thanks
@jmal98 using the build of the latest image my playbook is working and managing my windows nodes! You should publish this to the docker registry!
Great, glad it fixed it.
The update image has been pushed to Docker hub.
Not really an issue, but I was wondering if you would be able to create a similar dockerfile where ansible is configured to connect to windows machines. This is one article that explains it (also it is documented by ansible itself).
http://www.tomsitpro.com/articles/how-to-use-ansible-on-windows,1-3479.html