Containerized Ansible SSH-ing to Windows DockerHost

Afternoon!

I am attempting to set up an Ansible Docker container for managing both other containers running in Docker, as well as my host machine (Running Windows 10).

Using Ansible 2.8, I’m attempting to get the SSH connection to my host machine to work, as using WinRM isn’t ideal for my scenario. I have set up OpenSSH Server on my machine, and done all of the steps to allow SSH tunneling from my container to my host machine. I can even go so far as to “docker exec -it ansible bash” into my container, then run an “ssh dockerhost” command, and it successfully uses my SSH keys to authenticate and SSH back into my host machine.

My problem comes when I attempt to use Ansible from inside the container to ping my host machine. Whenever I try to run “ansible dockerhost -m ping”, I’m met with this error:

I’m not sure I fully follow how you are trying to set this up, but windows is not supported for running ansible itself, as stated here: https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#control-node-requirements

I am out of touch with the latest state of windows support for containers but I think you’d need to run a linux container for the ansible controller. I think that may be possible now with latest versions, but as I say I’m not sure.

Sorry that’s probably not what you want to hear. Personally I have used WSL aka ‘Bash on Ubuntu on Windows’ for some time now and it works just fine for running playbooks from while developing playbooks. I have full blown linux nodes for production ansible runs though.

Jon

Hey J,

My initial post may have been a bit confusing: I am running my Ansible controller inside of a Linux container already, and it functions well when I use that Ansible controller container to control other Linux-based environments.

My problem is that my Ansible container is running in Docker on a Windows host machine. I’m attempting to make it so that my Ansible Linux container running in Docker can control my host machine as a Windows-based Ansible Node.

To reiterate from my initial post, I’m opting to try the latest experimental SSH support for controlling Windows-based nodes (WinRM isn’t a good fit for us at the moment). I can successfully SSH from my Ansible Linux container to my Windows docker host machine, but I can’t seem to get Ansible to successfully ping my Windows host machine.

Hope that clears some confusion,

Thanks!

The thing that’s confused me is that you have set

ansible_python_interpreter=‘C:\Program Files\Python\Python3.6.4’

which looks like you are trying to use a windows installation of python to run with, and I’m pretty certain that’s not going to fly.

Even when you are using ssh to talk to your windows hosts, the modules you will use will still be implemented in powershell.

Hope that helps a bit. I haven’t tried the ssh support myself yet, so I’m sorry I can’t hel with that part.

Jon

Definitely a bit of a Rube Goldberg setup there, but no reason it shouldn’t work. The big problem is that you need to be using the Windows modules to manage the Windows host (eg, win_ping, not ping).

win_ping it is, I’ll stop messing with ping itself then.

So my question surrounding win_ping still stands, I’m getting a StackOverflowError back after the process hangs for an extended period. Any more insights from anyone before I head over to the github and post it as a possible bug/issue?