I am planning to build test environment using ansible, jenkins and docker together.The plan is like this.
Create ansible playbooks for every tool that you are using in
I am using a similar but different approach:
Define Dockerfiles or chef/puppet/ansible/salt provisioning. As in your approach.
Putting those descriptions under version control. As in your approach.
Using Jenkins A to CI- and Nightly Building Images and Uploading them into a registry. In order to manage different versions and keeping old images. This introduces a image registry in your diagram.
Extending those images with Jenkins-Swarm slaves. This enables ad-hoc deployment in your Jenkins environment.
Here I separate between building of the software and the building of the build slaves themselves.
I deploy a Jenkins B in order to build the software on environments.
Now I choose between container that I want to deploy permanently and build containers I want to deploy on demand.
Diagram:
If you want to test with a docker image that has the latest available version of a given package on a given OS, then you need to setup nightly docker image rebuilds. I have a very small, simple project that can get you up and running with nightly docker image rebuilds at https://github.com/zbeekman/nightly-docker-rebuild. I use this to rebuild GCC trunk from source, but you could just as easily use it to install/upgrade packages from a package manager, or deal with any other build/runtime dependency that might be updated upstream and have a potential impact on your project. This way you can catch the issues early, before clients/users encounter them.