Introducing Ansible Container

Many thanks to Joshua Ginsberg and Chris Houseknecht of Ansible for
starting this new project:

https://github.com/ansible/ansible-container

Still in its infancy, so please take it for a spin and let us know how
it works for you. Patches and bug reports encouraged.

What does it do, exactly? Permit me to crib from the excellent README.md:

Ansible Container is a tool to build Docker images and orchestrate
containers using only Ansible playbooks. It does this by building a
container from which to execute Ansible and connects to your other
containers via the Docker engine instead of SSH.

And when you're ready to deploy to the cloud, use Ansible Container's
shipit command to generate an Ansible Role that deploys your
application. The role is generated from your project's docker-compose
file, leveraging the time and work already invested in Docker compose.

Why not just use standard Docker tools?

* A Dockerfile is not much more than a script with hand-crafted shell
commands. We're well past the point where we should be managing build
processes with manually maintained series of shell scripts. That's why
we wrote Ansible in the first place, and this is just as applicable to
containers.

* Ansible Container permits orchestration even during the build
process, whereas docker build does not. For example, in a Django
project, your VCS may contain a bunch of sources for static assets
that need to be compiled and then collected. With Ansible Container,
you can compile the static assets in your Django container and then
collect them into your static file serving container.

* Many people use Docker for development environments only but then
use Ansible playbooks to push out to staging or production. This
allows you to use the same playbooks and roles in your Docker dev
environment as in your production environments.

* Ansible Container does all of this without installing SSH, leaving
Ansible artifacts on your built images, or having excess layers to the
union filesystem.

* When you're ready to deploy to the cloud, Docker compose leaves you
with only one option. Ansible Container's shipit command enables the
deployment of your app on a number of cloud infrastructures without
you having to write a single line of code.

Try it out!

--g

This sounds great!

Good news !!

I try since yesterday to plug ansible to my docker + container :stuck_out_tongue:
I try ansible-container tomorow :slight_smile:

If it breaks, you get to keep both halves :slight_smile:

(But seriously, thanks for trying it out, please give us feedback)

hi greg - any idea why i would get this error when running ansible-container build from the test directory ?

“ImportError: No module named docker.engine”

tried this on ubuntu @ fedora - same issue.

Cheers
Mike

Did you install Docker-compose?

Hi Mike,

take a look at this:

https://github.com/ansible/ansible-container/commit/6856643b49a40d0b057ea43b42a97837a1e5a2c4

Vincent

thanks vincent, that fixed it for me.

i also needed recent version of docker-py

pip install -U docker-py=1.7.1

to avoid:

ImportError: cannot import name create_ipam_config
https://github.com/docker/compose/issues/2792

Thanks
Mike

Hi, I am trying out ansible-container to orchestrate containers on a k8s cluster…
I am seeing the below error during the shipit stage:

Any help will be appreciated …

#ansible-container --debug shipit kube --pull-from

Cleaning up temporary directory /tmp/tmpsX8ySy…
Creating role path /<ansible_directory>/example/ansible/roles/example-kubernetes
Rendering template for test/test.j2.yml
shipit_role/test.j2.yml
Traceback (most recent call last):
File “/usr/lib/python2.7/site-packages/ansible_container-0.1-py2.7.egg/container/cli.py”, line 154, in commandline
getattr(engine, u’cmdrun_{}'.format(args.subcommand))(**vars(args))
File “/usr/lib/python2.7/site-packages/ansible_container-0.1-py2.7.egg/container/engine.py”, line 337, in cmdrun_shipit
shipit_engine_obj.run()
File “/usr/lib/python2.7/site-packages/ansible_container-0.1-py2.7.egg/container/shipit/kubernetes/engine.py”, line 28, in run
self.init_role()
File “/usr/lib/python2.7/site-packages/ansible_container-0.1-py2.7.egg/container/shipit/base_engine.py”, line 139, in init_role
**context)
File “/usr/lib/python2.7/site-packages/ansible_container-0.1-py2.7.egg/container/utils.py”, line 68, in jinja_render_to_temp
j2_tmpl = j2_env.get_template(template_file)
File “/usr/lib64/python2.7/site-packages/jinja2/environment.py”, line 812, in get_template
return self._load_template(name, self.make_globals(globals))
File “/usr/lib64/python2.7/site-packages/jinja2/environment.py”, line 774, in _load_template
cache_key = self.loader.get_source(self, name)[1]
File “/usr/lib64/python2.7/site-packages/jinja2/loaders.py”, line 187, in get_source
raise TemplateNotFound(template)
TemplateNotFound: shipit_role/test.j2.yml