Clarifying docker and docker_image module

So this bug just hit my radar:
https://github.com/ansible/ansible/issues/9104

In a nutshell, when you run the command ansible localhost -m docker -a ‘image=foo state=present’ nothing happens and success is returned. The bug reporter expected that the image they specified would have been downloaded from dockerhub.

Reading the documentation and the code for the docker and docker_image modules, I’m not sure if that’s the correct outcome. At some level it seems like docker_image should be dealing with anything that directly targets docker images and the docker module should deal with anything that directly targets docker containers (My understanding of docker is that images are the persistent, on disk implementations of a set of programs that you could potentially run. containers are an actually running image).

So asking to download an image from docker hub as the bug reporter wants seems like it belongs in docker_image.

Doing this, however, would require changes to the docker and docker_image modules, some of which may be backwards incompatible. For instance, the image parameter could be made non-mandatory in the docker module, the name parameter could become mandatory for some combinations of the state parameter. docker_image could change behaviour to search dockerhub by default or, instead, grow new parameters to use dockerhub to retrieve images that are not yet available. The docker module’s state=present might go away as it doesn’t seem that a container being “present” provides anything useful above what state=running already does.

Does this seem like an overall good general strategy for these two modules?

Do the changes seem like worthwhile clarifications to the separation between the two modules or should we leave the old API alone as much as possible and bolt new features on top of the existing modules?

-Toshio

BTW, from recent discussion on -project, and another with Toshio and James off-list which I’m recapping here…

My current feeling is docker-image doesn’t do a lot. It’s basically a wrapper around the docker build command, which is not very functional.

The magic happens in the regular docker module, which should support pull, starting, and so on.

I think we ought to remove docker-image in 1.8, and make sure that if count=0 or state=absent on a docker module invocation, there can be something like a purge=yes flag that can optionally remove the image if provided.

It’s most likely, I think that, docker builds would be fired by Jenkins/other-CI or the DockerHub hooks, not from an ansible playbook, and the playbook is much more likely to be used as a lightweight-cloud system than a build system.

For those using the docker-image module today, I’d be interested in your use case cases, as well as input from others not using it.

Thanks!