4 ms·
Here's a nice way to do Docker builds with Ansible, which allow using the template engine and all of that good stuff: https://github.com/ansible/ansible-docker
by mpdehaan2 12y ago
Here's a nice way to do Docker builds with Ansible, which allow using the template engine and all of that good stuff:
https://github.com/ansible/ansible-docker-base https://github.com/ansible/ansible-docker-base
(Disclaimer: wrote Ansible)
- zwischenzug 12y agoThanks! I may use those as templates to improve this: https://github.com/ianmiell/shutit/blob/master/library/ansible/ansible.py#L30 https://github.com/ianmiell/shutit/blob/master/library/ansib...
- renaudg 12y agoVery nice Michael ! As a longtime Ansible user who's just starting out dockerizing our apps, I find that there's significant refactoring needed when trying to reuse existing playbooks & roles to provision Docker containers. In the current model we have a single playbook driven by an EC2 dynamic inventory, and each server definition under "roles/" (with some reuse between them, obviously). All in single repo. With Docker it seems like this layout needs to be turned completely on its head, because a Dockerfile (unlike an Ansible playbook) can only define a single container type, and to make things even harder there can only be one per directory (something similar to "make -f" would have been useful) So, the logical directory layout in this situation is probably one directory + Dockerfile per container, with a corresponding Ansible playbook + role in each. That's awful for code reuse and quite a bit of refactoring though. Has anyone managed to do it more elegantly ?
- __alexs 12y agoI attempted to do something like this when figuring out our build problems but it didn't really work for me. It doesn't solve the problem of actually getting configuration into the build very well because it still relies on Dockerfiles and has the added side effect of making the cache mostly useless. Maybe I was just doing it wrong? I also attempted to try Ansible for deploying containers and had issues with both of these bugs: https://github.com/ansible/ansible-modules-core/issues/27 https://github.com/ansible/ansible-modules-core/issues/27 https://github.com/ansible/ansible-modules-core/issues/188 https://github.com/ansible/ansible-modules-core/issues/188 Do people actually use Ansible to control Docker in practice? It would be great to have something that was a step up from building random Python scripts from scratch :) (Disclaimer: I'm not very good at Ansible.)
- aidanhs 12y agoFor my purposes, I wrote a makefile which starts up a container with ssh, then provisions it with ansible (as you would with any normal remote host). This meant a) I could reuse existing scripts to provision normal server b) docker could be used to test the ansible scripts were actually capturing everything required. The cache point was a bit of a pain though, I confess.
- zwischenzug 12y agoOur experience was that Dockerfiles were almost completely useless except for the most trivial of cases. We effectively ditched them, spitting out Dockerfiles that implant the ShutIt functionality and no more, eg: curl https://raw.githubusercontent.com/ianmiell/shutit/master/library/osquery/dockerfile/Dockerfile | docker build --no-cache -