]> git.immae.eu Git - github/fretlink/docker-ansible.git/blame - README.md
Add: support for CentOS 6.
[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
e6ab6fea 17- OS: Debian (jessie, wheezy), Ubuntu (trusty, precise), CentOS (6)
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`
e6ab6fea 30 - `williamyeh/ansible:centos6`
ebfd2bf2
WY
31
32- onbuild series:
33
34 - `williamyeh/ansible:debian8-onbuild`
35 - `williamyeh/ansible:debian7-onbuild`
36 - `williamyeh/ansible:ubuntu14.04-onbuild`
37 - `williamyeh/ansible:ubuntu12.04-onbuild`
e6ab6fea 38 - `williamyeh/ansible:centos6-onbuild`
ebfd2bf2 39
d3c54163
WY
40
41## Why yet another Ansible image for Docker?
42
43There 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?
44
45In 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:
46
47- *Base OS image* - It provides only `centos:centos7` and `ubuntu:14.04`. Insufficent for me.
48
49- *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.
50
51Therefore, I built these Docker images on my own.
52
53
54## Usage
55
56Used mostly as a *base image* for configuring, with Ansible, other software stack on some specified Linux distribution.
57
58Take 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:
59
60```ruby
61# Vagrantfile
62
63Vagrant.configure(2) do |config|
64
65 # ==> Choose a Vagrant box to emulate Linux distribution...
66 config.vm.box = "ubuntu/trusty64"
67 #config.vm.box = "hashicorp/precise64"
68 #config.vm.box = "chef/debian-7.8"
e6ab6fea
WY
69 #config.vm.box = "chef/centos-6.6"
70
d3c54163
WY
71
72 # ==> Executing Ansible...
73 config.vm.provision "ansible" do |ansible|
74 ansible.playbook = "playbook.yml"
75 end
76
77end
78```
79
ebfd2bf2
WY
80Virtual machines can emulate a variety of Linux distributions with good quality, at the cost of runtime overhead.
81
d3c54163
WY
82
83Docker 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:
84
85
86```dockerfile
87# Dockerfile
88
89# ==> Choose a base image to emulate Linux distribution...
90FROM williamyeh/ansible:ubuntu14.04
91#FROM williamyeh/ansible:ubuntu12.04
ebfd2bf2 92#FROM williamyeh/ansible:debian8
d3c54163 93#FROM williamyeh/ansible:debian7
e6ab6fea 94#FROM williamyeh/ansible:centos6
d3c54163 95
ebfd2bf2 96
d3c54163
WY
97# ==> Copying Ansible playbook...
98WORKDIR /tmp
99COPY . /tmp
100
101# ==> Creating inventory file...
102RUN echo localhost > inventory
103
104# ==> Executing Ansible...
105RUN ansible-playbook -i inventory playbook.yml \
106 --connection=local --sudo
107```
108
ebfd2bf2
WY
109Or, more simple with `onbuild` series:
110
111```dockerfile
112# Dockerfile
113
114# ==> Choose a base image to emulate Linux distribution...
115FROM williamyeh/ansible:ubuntu14.04-onbuild
116#FROM williamyeh/ansible:ubuntu12.04-onbuild
117#FROM williamyeh/ansible:debian8-onbuild
118#FROM williamyeh/ansible:debian7-onbuild
e6ab6fea 119#FROM williamyeh/ansible:centos6-onbuild
ebfd2bf2
WY
120
121
122# ==> Specify playbook filename; default = "playbook.yml"
123#ENV PLAYBOOK playbook.yml
124
125# ==> Specify inventory filename; default = "/etc/ansible/hosts"
126#ENV INVENTORY inventory.ini
127
128# ==> Executing Ansible...
129RUN ansible-playbook-wrapper
130```
131
132
133
d3c54163
WY
134With 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!
135
ebfd2bf2
WY
136If better OS emulation (virtualization) isn't required, the Docker approach (containerization) should give you a more efficient Ansible experience.
137
d3c54163
WY
138
139
140## License
141
142Author: William Yeh <william.pjyeh@gmail.com>
143
144Licensed under the Apache License V2.0. See the [LICENSE file](LICENSE) for details.