Introducing Ansible Container

262 views
Skip to first unread message

Greg DeKoenigsberg

unread,
Jun 2, 2016, 11:49:43 AM6/2/16
to ansible-devel, Ansible Project
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

--
Greg DeKoenigsberg
Ansible Community Guy


--
Greg DeKoenigsberg
Ansible Community Guy

Chris Short

unread,
Jun 2, 2016, 11:54:30 AM6/2/16
to Ansible Project, ansibl...@googlegroups.com
This sounds great!

Clément VALENTIN

unread,
Jun 2, 2016, 12:03:06 PM6/2/16
to Ansible Development, ansible...@googlegroups.com
Good news !!

I try since yesterday to plug ansible to my docker + container :p
I try ansible-container tomorow :)

Greg DeKoenigsberg

unread,
Jun 2, 2016, 12:34:23 PM6/2/16
to Clément VALENTIN, Ansible Project, ansible-devel

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

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

--
You received this message because you are subscribed to the Google Groups "Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-deve...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

mike hepburn

unread,
Jun 7, 2016, 9:05:36 AM6/7/16
to Ansible Project, ansibl...@googlegroups.com
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

 
root@base:~/ansible-container/test# ansible-container --debug build
No module named docker.engine
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/ansible_container-0.1-py2.7.egg/container/cli.py", line 164, in commandline
    **vars(args))
  File "/usr/local/lib/python2.7/dist-packages/ansible_container-0.1-py2.7.egg/container/engine.py", line 210, in cmdrun_build
    engine_obj = load_engine(engine, base_path)
  File "/usr/local/lib/python2.7/dist-packages/ansible_container-0.1-py2.7.egg/container/utils.py", line 113, in load_engine
    mod = importlib.import_module('container.%s.engine' % engine_name)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
ImportError: No module named docker.engine

 
root@base:~/ansible-container/test# docker-compose -v
docker-compose version 1.7.1, build 6c29830
root@base:~/ansible-container/test# 

Greg DeKoenigsberg

unread,
Jun 7, 2016, 9:11:44 AM6/7/16
to Ansible Project

Did you install Docker-compose?

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/cfcebfdd-81f8-4b7d-af0a-6fb1f4d33cd2%40googlegroups.com.

Vincent Van der Kussen

unread,
Jun 7, 2016, 9:26:19 AM6/7/16
to ansible...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.

mike hepburn

unread,
Jun 7, 2016, 5:44:08 PM6/7/16
to Ansible Project
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

Thanks
Mike

Ramkumar GN

unread,
Jul 5, 2016, 5:45:26 PM7/5/16
to Ansible Project
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 <registry>

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
Reply all
Reply to author
Forward
0 new messages