Experimantal support for Windows Containers

Hi,
I’ve hacked a bit on Windows Container support for Ansible during the weekend, and have pushed a working copy here:
https://github.com/trondhindenes/ansible/tree/win_containers

Essentially the win_containers thingy is implemented as separate connection and shell types, and get invoked by using a hosts file entry like this:

awscontainer ansible_host=10.245.8.26 ansible_connection=winrm_containers containerid=

This works quite simply by “regular” remoting to the host, and then using the “invoke-command -ContainerId ” from there to execute the command.

I’ve only tested this on Windows 2016 running a container based on the “microsoft/windowsservercore” image.

I think Ansible could be a powerful thing to use with Windows containers, for the same reasons as the “ansible containers” project - it allows for much more advanced configuration/building of an image than what a Dockerfile does, and especially given Windows’ reliance on api’s instead of text files for management, I’d say this is even more true on Windows than on Linux.

My code is very rough since I don’t fully understand the internals of Ansible, it was just meant as an excercise.

Noice- looking forward to playing around with this a little more after 2.3 is out the door (and Windows containers in general- haven’t touched them since 2016 RTM’d).

I think we can probably do something a little more integrated on the connection-side- Windows jump-host support in the WinRM connection plugin is something that’s getting asked for a little more frequently, and this is basically the same use-case (except that it’s an on-machine jump instead of networked). I’ve prototyped a couple different things over the years- maybe I ought to roadmap it for 2.4 and just get it done.

Thanks!

-Matt

Yup - more than anything this branch proves who little I understand of the Ansible internals :slight_smile:

It was just meant as a prototype to see if it would work - and you’re absolutely right, its essentially a jump-host. I’m sure there are way better ways of doing this.

Still, this is something we might actually need if (when) we move into containers - we have so much stuff we need to inject that would be really tricky to do using just Dockerfiles.

Thanks for blazing a trail on this. Looking forward to giving it a try when I have the chance.

Jon