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