# Introducing Ansible Container

**URL:** <https://forum.ansible.com/t/introducing-ansible-container/21646>\
**Category:** Ansible Project\
**Created:** [June 2, 2016, 3:49pm UTC](https://forum.ansible.com/t/introducing-ansible-container/21646 "2016-06-02T15:49:36Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Greg\_DeKoenigsberg1](https://avatars.discourse-cdn.com/v4/letter/g/838e76/32.png) [@Greg\_DeKoenigsberg1](https://forum.ansible.com/u/Greg_DeKoenigsberg1)\
**Post date:** [June 2, 2016, 3:49pm UTC](https://forum.ansible.com/t/introducing-ansible-container/21646/1 "2016-06-02T15:49:36Z")

</div>

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

[https://github.com/ansible/ansible-container](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

---

<div class="post-metadata">

**Author:** ![Chris\_Short](https://avatars.discourse-cdn.com/v4/letter/c/ac8455/32.png) [@Chris\_Short](https://forum.ansible.com/u/Chris_Short)\
**Post date:** [June 2, 2016, 3:54pm UTC](https://forum.ansible.com/t/introducing-ansible-container/21646/2 "2016-06-02T15:54:30Z")

</div>

This sounds great!

---

<div class="post-metadata">

**Author:** ![Clement\_VALENTIN](https://avatars.discourse-cdn.com/v4/letter/c/839c29/32.png) [@Clement\_VALENTIN](https://forum.ansible.com/u/Clement_VALENTIN)\
**Post date:** [June 2, 2016, 4:02pm UTC](https://forum.ansible.com/t/introducing-ansible-container/21646/3 "2016-06-02T16:02:59Z")

</div>

Good news !!

I try since yesterday to plug ansible to my docker + container 😛  
I try ansible-container tomorow 🙂

---

<div class="post-metadata">

**Author:** ![Greg\_DeKoenigsberg1](https://avatars.discourse-cdn.com/v4/letter/g/838e76/32.png) [@Greg\_DeKoenigsberg1](https://forum.ansible.com/u/Greg_DeKoenigsberg1)\
**Post date:** [June 2, 2016, 4:34pm UTC](https://forum.ansible.com/t/introducing-ansible-container/21646/4 "2016-06-02T16:34:17Z")

</div>

If it breaks, you get to keep both halves 🙂

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

---

<div class="post-metadata">

**Author:** ![mike\_hepburn](https://avatars.discourse-cdn.com/v4/letter/m/7ea924/32.png) [@mike\_hepburn](https://forum.ansible.com/u/mike_hepburn)\
**Post date:** [June 7, 2016, 9:22am UTC](https://forum.ansible.com/t/introducing-ansible-container/21646/5 "2016-06-07T09:22:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Greg\_DeKoenigsberg1](https://avatars.discourse-cdn.com/v4/letter/g/838e76/32.png) [@Greg\_DeKoenigsberg1](https://forum.ansible.com/u/Greg_DeKoenigsberg1)\
**Post date:** [June 7, 2016, 1:11pm UTC](https://forum.ansible.com/t/introducing-ansible-container/21646/6 "2016-06-07T13:11:38Z")

</div>

Did you install Docker-compose?

---

<div class="post-metadata">

**Author:** ![Vincent\_Van\_der\_Kuss](https://avatars.discourse-cdn.com/v4/letter/v/7c8e57/32.png) [@Vincent\_Van\_der\_Kuss](https://forum.ansible.com/u/Vincent_Van_der_Kuss)\
**Post date:** [June 7, 2016, 1:26pm UTC](https://forum.ansible.com/t/introducing-ansible-container/21646/7 "2016-06-07T13:26:07Z")

</div>

Hi Mike,

take a look at this:

[https://github.com/ansible/ansible-container/commit/6856643b49a40d0b057ea43b42a97837a1e5a2c4](https://github.com/ansible/ansible-container/commit/6856643b49a40d0b057ea43b42a97837a1e5a2c4)

Vincent

---

<div class="post-metadata">

**Author:** ![mike\_hepburn](https://avatars.discourse-cdn.com/v4/letter/m/7ea924/32.png) [@mike\_hepburn](https://forum.ansible.com/u/mike_hepburn)\
**Post date:** [June 7, 2016, 9:44pm UTC](https://forum.ansible.com/t/introducing-ansible-container/21646/8 "2016-06-07T21:44:07Z")

</div>

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](https://github.com/docker/compose/issues/2792)

Thanks  
Mike

---

<div class="post-metadata">

**Author:** ![Ramkumar\_GN](https://avatars.discourse-cdn.com/v4/letter/r/7feea3/32.png) [@Ramkumar\_GN](https://forum.ansible.com/u/Ramkumar_GN)\
**Post date:** [July 5, 2016, 4:03pm UTC](https://forum.ansible.com/t/introducing-ansible-container/21646/9 "2016-07-05T16:03:31Z")

</div>

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
