]> git.immae.eu Git - github/fretlink/docker-ansible.git/blame - README.md
Add: onbuild and debian8.
[github/fretlink/docker-ansible.git] / README.md
CommitLineData
d3c54163
WY
1Docker-Ansible base images
2===================
3
4
5## Summary
6
9a0d65e4 7Repository name in Docker Hub: **[williamyeh/ansible](https://registry.hub.docker.com/u/williamyeh/ansible/)**
d3c54163
WY
8
9This repository contains Dockerized [Ansible](https://github.com/ansible/ansible), published to the public [Docker Hub](https://registry.hub.docker.com/) via **automated build** mechanism.
10
11
12
13## Configuration
14
15These are Docker images for [Ansible](https://github.com/ansible/ansible) software, installed in a selected Linux distributions.
16
ebfd2bf2 17- OS: Debian (jessie, wheezy), Ubuntu (trusty, precise).
d3c54163
WY
18
19- Ansible: usually the latest version.
20
21
ebfd2bf2
WY
22## Images and tags
23
24- normal series:
25
26 - `williamyeh/ansible:debian8`
27 - `williamyeh/ansible:debian7`
28 - `williamyeh/ansible:ubuntu14.04`
29 - `williamyeh/ansible:ubuntu12.04`
30
31- onbuild series:
32
33 - `williamyeh/ansible:debian8-onbuild`
34 - `williamyeh/ansible:debian7-onbuild`
35 - `williamyeh/ansible:ubuntu14.04-onbuild`
36 - `williamyeh/ansible:ubuntu12.04-onbuild`
37
d3c54163
WY
38
39## Why yet another Ansible image for Docker?
40
41There has been quite a few Ansible images for Docker (e.g., [search](https://registry.hub.docker.com/search?q=ansible) in the Docker Hub), so why reinvent the wheel?
42
43In the beginning I used the [`ansible/ansible-docker-base`](https://github.com/ansible/ansible-docker-base) created by Ansible Inc. It worked well, but left some room for improvement:
44
45- *Base OS image* - It provides only `centos:centos7` and `ubuntu:14.04`. Insufficent for me.
46
47- *Unnecessary dependencies* - It installed, at the very beginning of its Dockerfile, the `software-properties-common` package, which in turns installed some Python packages. I prefered to incorporate these stuff only when absolutely needed.
48
49Therefore, I built these Docker images on my own.
50
51
52## Usage
53
54Used mostly as a *base image* for configuring, with Ansible, other software stack on some specified Linux distribution.
55
56Take Debian/Ubuntu for example. To test an Ansible `playbook.yml` against a variety of Linux distributions, we may use [Vagrant](https://www.vagrantup.com/) as follows:
57
58```ruby
59# Vagrantfile
60
61Vagrant.configure(2) do |config|
62
63 # ==> Choose a Vagrant box to emulate Linux distribution...
64 config.vm.box = "ubuntu/trusty64"
65 #config.vm.box = "hashicorp/precise64"
66 #config.vm.box = "chef/debian-7.8"
67
68 # ==> Executing Ansible...
69 config.vm.provision "ansible" do |ansible|
70 ansible.playbook = "playbook.yml"
71 end
72
73end
74```
75
ebfd2bf2
WY
76Virtual machines can emulate a variety of Linux distributions with good quality, at the cost of runtime overhead.
77
d3c54163
WY
78
79Docker to be a rescue. Now, with these **williamyeh/ansible** series, we may test an Ansible `playbook.yml` against a variety of Linux distributions as follows:
80
81
82```dockerfile
83# Dockerfile
84
85# ==> Choose a base image to emulate Linux distribution...
86FROM williamyeh/ansible:ubuntu14.04
87#FROM williamyeh/ansible:ubuntu12.04
ebfd2bf2 88#FROM williamyeh/ansible:debian8
d3c54163
WY
89#FROM williamyeh/ansible:debian7
90
ebfd2bf2 91
d3c54163
WY
92# ==> Copying Ansible playbook...
93WORKDIR /tmp
94COPY . /tmp
95
96# ==> Creating inventory file...
97RUN echo localhost > inventory
98
99# ==> Executing Ansible...
100RUN ansible-playbook -i inventory playbook.yml \
101 --connection=local --sudo
102```
103
ebfd2bf2
WY
104Or, more simple with `onbuild` series:
105
106```dockerfile
107# Dockerfile
108
109# ==> Choose a base image to emulate Linux distribution...
110FROM williamyeh/ansible:ubuntu14.04-onbuild
111#FROM williamyeh/ansible:ubuntu12.04-onbuild
112#FROM williamyeh/ansible:debian8-onbuild
113#FROM williamyeh/ansible:debian7-onbuild
114
115
116# ==> Specify playbook filename; default = "playbook.yml"
117#ENV PLAYBOOK playbook.yml
118
119# ==> Specify inventory filename; default = "/etc/ansible/hosts"
120#ENV INVENTORY inventory.ini
121
122# ==> Executing Ansible...
123RUN ansible-playbook-wrapper
124```
125
126
127
d3c54163
WY
128With Docker, we can test any Ansible playbook against any version of any Linux distribution without the help of Vagrant. More lightweight, and more portable across IaaS, PaaS, and even CaaS (Container as a Service) providers!
129
ebfd2bf2
WY
130If better OS emulation (virtualization) isn't required, the Docker approach (containerization) should give you a more efficient Ansible experience.
131
d3c54163
WY
132
133
134## License
135
136Author: William Yeh <william.pjyeh@gmail.com>
137
138Licensed under the Apache License V2.0. See the [LICENSE file](LICENSE) for details.