geerlingguy/docker-ubuntu1804-ansible

pip install testinfra

nickjj opened this issue · 8 comments

I'd like to be able to run TestInfra tests inside of your Docker test shim to test roles but that would require TestInfra to be installed in this image.

I've done some local tests and this approach is so much faster than Molecule (20 seconds to molecule verify vs 5 seconds by running testinfra directly). I also have some tricks up my sleeve to turn that 5 seconds to half a second for a lot of tests.

If you agree with this, please make the change to all of your base Docker images!

@nickjj - I'm a bit mixed on this:

  • These images are meant to have ansible... and maybe some related dependencies like python; but they're not used explicitly/only for testing Ansible roles (I use them in a lot of different scenarios).
  • If I make the change here I would want to change it across all my 8+ OS images, so I would need to do it across the board (not a big deal though).
  • In the spirit of keeping things as trim and Docker-y as possible, I'd rather have a ubuntu1804-ansible-testing image maybe instead, which would build on top of this image and have molecule, testinfra, ansible-lint, etc. (any testing-related stuff) on top of it.

But then again, that would be two sets of projects to maintain.

Another option: each of these images could have a latest tag, and a testing tag, or something like that. That might be way easier to maintain, since it could be one project per OS, with multiple tags managed on Docker Hub via branches on GitHub.

I like the idea of having a testing tag. Should we start with testinfra, yamllint, ansible-lint and flake8, or do you feel molecule is important to have too?

@nickjj - Molecule will be more and more important, especially for role testing since it will be adopted as an official Ansible project, so I'd definitely want it in there :)

Yep, but I don't think I'll be using it. It's waaaaaay too slow on a Windows / WSL / Docker box. Luckily your base Docker image, test shim and about 50 lines of Bash was enough to put together a proof of concept CLI that is up to 40x faster than Molecule for testing with testinfra.

Anyways, happy to see you're opening to doing something like the testing tags.

Do you want me to send a PR for the ubuntu 18/16 + debian 9/8 images?

I got a working build on Docker Hub: https://hub.docker.com/r/geerlingguy/docker-ubuntu1804-ansible/tags/

Can you see if that branch works for you?

@nickjj ^^ forgot to add a mention :)

Yep it works (all of the binaries are accessible), but I might end up forking it still to remove Molecule.

Sounds good! Closing this issue, will clone it over into the other repos.