]> git.immae.eu Git - github/fretlink/docker-ansible.git/blame - README.md
Update openssl and ca-certificates ONBUILD
[github/fretlink/docker-ansible.git] / README.md
CommitLineData
d3c54163
WY
1Docker-Ansible base images
2===================
3
eb32e88f 4[![Circle CI](https://circleci.com/gh/William-Yeh/docker-ansible.svg?style=shield)](https://circleci.com/gh/William-Yeh/docker-ansible) [![Build Status](https://travis-ci.org/William-Yeh/docker-ansible.svg?branch=master)](https://travis-ci.org/William-Yeh/docker-ansible)
02c34901 5
d3c54163
WY
6
7## Summary
8
9a0d65e4 9Repository name in Docker Hub: **[williamyeh/ansible](https://registry.hub.docker.com/u/williamyeh/ansible/)**
d3c54163
WY
10
11This repository contains Dockerized [Ansible](https://github.com/ansible/ansible), published to the public [Docker Hub](https://registry.hub.docker.com/) via **automated build** mechanism.
12
13
14
15## Configuration
16
17These are Docker images for [Ansible](https://github.com/ansible/ansible) software, installed in a selected Linux distributions.
18
ae06b63d 19- OS: Debian (jessie, wheezy), Ubuntu (trusty, precise), CentOS (7, 6), Alpine (3).
d3c54163 20
14e54a03
WY
21- Ansible: three version series -
22
23 1. the most recent *stable* version;
24 2. old 1.9 version;
25 3. the *experimental* version.
d3c54163
WY
26
27
ebfd2bf2
WY
28## Images and tags
29
de4433f3 30### Stable version (installed from official PyPI repo):
930848e7 31
aa3cb4d5 32- Normal series:
ebfd2bf2
WY
33
34 - `williamyeh/ansible:debian8`
35 - `williamyeh/ansible:debian7`
36 - `williamyeh/ansible:ubuntu14.04`
37 - `williamyeh/ansible:ubuntu12.04`
02c34901 38 - `williamyeh/ansible:centos7`
e6ab6fea 39 - `williamyeh/ansible:centos6`
ae06b63d 40 - `williamyeh/ansible:alpine3`
ebfd2bf2 41
ffe10e81 42- Onbuild series (*recommended for common cases*):
ebfd2bf2
WY
43
44 - `williamyeh/ansible:debian8-onbuild`
45 - `williamyeh/ansible:debian7-onbuild`
46 - `williamyeh/ansible:ubuntu14.04-onbuild`
47 - `williamyeh/ansible:ubuntu12.04-onbuild`
02c34901 48 - `williamyeh/ansible:centos7-onbuild`
e6ab6fea 49 - `williamyeh/ansible:centos6-onbuild`
ae06b63d 50 - `williamyeh/ansible:alpine3-onbuild`
ebfd2bf2 51
14e54a03
WY
52### Old 1.9 version:
53
54- Normal series:
55
56 - `williamyeh/ansible:1.9-debian8`
57 - `williamyeh/ansible:1.9-debian7`
58 - `williamyeh/ansible:1.9-ubuntu14.04`
59 - `williamyeh/ansible:1.9-ubuntu12.04`
60 - `williamyeh/ansible:1.9-centos7`
61 - `williamyeh/ansible:1.9-centos6`
62 - `williamyeh/ansible:1.9-alpine3`
63
64- Onbuild series (*recommended for common cases*):
65
66 - `williamyeh/ansible:1.9-debian8-onbuild`
67 - `williamyeh/ansible:1.9-debian7-onbuild`
68 - `williamyeh/ansible:1.9-ubuntu14.04-onbuild`
69 - `williamyeh/ansible:1.9-ubuntu12.04-onbuild`
70 - `williamyeh/ansible:1.9-centos7-onbuild`
71 - `williamyeh/ansible:1.9-centos6-onbuild`
72 - `williamyeh/ansible:1.9-alpine3-onbuild`
73
de4433f3 74### Experimental version (building directly from the git `master` source tree; use at your own risk!):
930848e7
WY
75
76- Normal series:
77
78 - `williamyeh/ansible:master-debian8`
79 - `williamyeh/ansible:master-debian7`
80 - `williamyeh/ansible:master-ubuntu14.04`
81 - `williamyeh/ansible:master-ubuntu12.04`
82 - `williamyeh/ansible:master-centos7`
83 - `williamyeh/ansible:master-centos6`
84
85- Onbuild series (*recommended for common cases*):
86
87 - `williamyeh/ansible:master-debian8-onbuild`
88 - `williamyeh/ansible:master-debian7-onbuild`
89 - `williamyeh/ansible:master-ubuntu14.04-onbuild`
90 - `williamyeh/ansible:master-ubuntu12.04-onbuild`
91 - `williamyeh/ansible:master-centos7-onbuild`
92 - `williamyeh/ansible:master-centos6-onbuild`
93
94
d3c54163 95
c20fa492
WY
96## For the impatient
97
98Here comes a simplest working example for the impatient.
99
100First, choose a base image you'd like to begin with. For example, `williamyeh/ansible:ubuntu14.04-onbuild`.
101
102Second, put the following `Dockerfile` along with your playbook directory:
103
104```
105FROM williamyeh/ansible:ubuntu14.04-onbuild
106
8287be90
WY
107# ==> Specify requirements filename; default = "requirements.yml"
108#ENV REQUIREMENTS requirements.yml
c20fa492 109
8287be90
WY
110# ==> Specify playbook filename; default = "playbook.yml"
111#ENV PLAYBOOK playbook.yml
112
113# ==> Specify inventory filename; default = "/etc/ansible/hosts"
114#ENV INVENTORY inventory.ini
c20fa492 115
ffe10e81 116# ==> Executing Ansible (with a simple wrapper)...
c20fa492
WY
117RUN ansible-playbook-wrapper
118```
119
120Third, `docker build .`
121
122Done!
123
de4433f3 124For more advanced usage, the role in Ansible Galaxy [`williamyeh/nginx`](https://galaxy.ansible.com/williamyeh/nginx/) demonstrates how to perform a simple smoke test (*configuration needs test, too!*) on a variety of (*containerized*) Linux distributions via [CircleCI](https://circleci.com/)'s Ubuntu 12.04 and [Travis CI](https://travis-ci.org/)’s Ubuntu 14.04 worker instances.
c20fa492
WY
125
126
127
128
d3c54163
WY
129## Why yet another Ansible image for Docker?
130
131There 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?
132
133In 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:
134
135- *Base OS image* - It provides only `centos:centos7` and `ubuntu:14.04`. Insufficent for me.
136
137- *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.
138
139Therefore, I built these Docker images on my own.
140
2fd99bb9 141**NOTE:** [`ansible/ansible-docker-base`](https://github.com/ansible/ansible-docker-base) announced in September 2015: “Ansible no longer maintains images in Dockerhub directly.”
d3c54163 142
c20fa492
WY
143### Comparison: image size
144
145```
146REPOSITORY TAG VIRTUAL SIZE
147--------------------------- ------------------- ------------
148ansible/centos7-ansible stable 367.5 MB
149ansible/ubuntu14.04-ansible stable 286.6 MB
150
ae06b63d 151williamyeh/ansible alpine3-onbuild 66.4 MB
c20fa492
WY
152williamyeh/ansible centos6-onbuild 264.2 MB
153williamyeh/ansible centos7-onbuild 275.3 MB
154williamyeh/ansible debian7-onbuild 134.4 MB
155williamyeh/ansible debian8-onbuild 178.3 MB
156williamyeh/ansible ubuntu12.04-onbuild 181.9 MB
157williamyeh/ansible ubuntu14.04-onbuild 238.3 MB
158```
159
160
d3c54163
WY
161## Usage
162
aa3cb4d5 163Used mostly as a *base image* for configuring other software stack on some specified Linux distribution(s).
d3c54163 164
c20fa492 165Take Debian/Ubuntu/CentOS for example. To test an Ansible `playbook.yml` against a variety of Linux distributions, we may use [Vagrant](https://www.vagrantup.com/) as follows:
d3c54163
WY
166
167```ruby
168# Vagrantfile
169
170Vagrant.configure(2) do |config|
171
172 # ==> Choose a Vagrant box to emulate Linux distribution...
173 config.vm.box = "ubuntu/trusty64"
ae06b63d
WY
174 #config.vm.box = "ubuntu/precise64"
175 #config.vm.box = "debian/jessie64"
176 #config.vm.box = "debian/wheezy64"
de4433f3 177 #config.vm.box = "bento/centos-7.2"
ae06b63d 178 #config.vm.box = "bento/centos-6.7"
de4433f3 179 #config.vm.box = "maier/alpine-3.3.1-x86_64"
e6ab6fea 180
d3c54163
WY
181
182 # ==> Executing Ansible...
183 config.vm.provision "ansible" do |ansible|
184 ansible.playbook = "playbook.yml"
185 end
186
187end
188```
189
ebfd2bf2
WY
190Virtual machines can emulate a variety of Linux distributions with good quality, at the cost of runtime overhead.
191
d3c54163
WY
192
193Docker 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:
194
195
196```dockerfile
197# Dockerfile
198
199# ==> Choose a base image to emulate Linux distribution...
200FROM williamyeh/ansible:ubuntu14.04
201#FROM williamyeh/ansible:ubuntu12.04
ebfd2bf2 202#FROM williamyeh/ansible:debian8
d3c54163 203#FROM williamyeh/ansible:debian7
02c34901 204#FROM williamyeh/ansible:centos7
e6ab6fea 205#FROM williamyeh/ansible:centos6
ae06b63d 206#FROM williamyeh/ansible:alpine3
d3c54163 207
ebfd2bf2 208
d3c54163
WY
209# ==> Copying Ansible playbook...
210WORKDIR /tmp
211COPY . /tmp
212
213# ==> Creating inventory file...
214RUN echo localhost > inventory
215
216# ==> Executing Ansible...
217RUN ansible-playbook -i inventory playbook.yml \
218 --connection=local --sudo
219```
220
ffe10e81 221You may also work with `onbuild` series, which take care of many routine steps for you:
ebfd2bf2
WY
222
223```dockerfile
224# Dockerfile
225
226# ==> Choose a base image to emulate Linux distribution...
227FROM williamyeh/ansible:ubuntu14.04-onbuild
228#FROM williamyeh/ansible:ubuntu12.04-onbuild
229#FROM williamyeh/ansible:debian8-onbuild
230#FROM williamyeh/ansible:debian7-onbuild
02c34901 231#FROM williamyeh/ansible:centos7-onbuild
e6ab6fea 232#FROM williamyeh/ansible:centos6-onbuild
ae06b63d 233#FROM williamyeh/ansible:alpine3-onbuild
ebfd2bf2
WY
234
235
8287be90
WY
236# ==> Specify requirements filename; default = "requirements.yml"
237#ENV REQUIREMENTS requirements.yml
238
239# ==> Specify playbook filename; default = "playbook.yml"
240#ENV PLAYBOOK playbook.yml
ebfd2bf2 241
8287be90
WY
242# ==> Specify inventory filename; default = "/etc/ansible/hosts"
243#ENV INVENTORY inventory.ini
ebfd2bf2 244
ffe10e81 245# ==> Executing Ansible (with a simple wrapper)...
ebfd2bf2
WY
246RUN ansible-playbook-wrapper
247```
248
249
250
d3c54163
WY
251With 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!
252
ebfd2bf2
WY
253If better OS emulation (virtualization) isn't required, the Docker approach (containerization) should give you a more efficient Ansible experience.
254
d3c54163
WY
255
256
257## License
258
259Author: William Yeh <william.pjyeh@gmail.com>
260
261Licensed under the Apache License V2.0. See the [LICENSE file](LICENSE) for details.