]> git.immae.eu Git - github/fretlink/docker-ansible.git/blob - README.md
Initial release.
[github/fretlink/docker-ansible.git] / README.md
1 Docker-Ansible base images
2 ===================
3
4
5 ## Summary
6
7 Repository name in Docker Hub: **[williamyeh/ansible]((https://registry.hub.docker.com/u/williamyeh/ansible/)**
8
9 This 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
15 These are Docker images for [Ansible](https://github.com/ansible/ansible) software, installed in a selected Linux distributions.
16
17 - OS: Debian (wheezy), Ubuntu (precise, trusty).
18
19 - Ansible: usually the latest version.
20
21
22
23 ## Why yet another Ansible image for Docker?
24
25 There 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?
26
27 In 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:
28
29 - *Base OS image* - It provides only `centos:centos7` and `ubuntu:14.04`. Insufficent for me.
30
31 - *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.
32
33 Therefore, I built these Docker images on my own.
34
35
36 ## Usage
37
38 Used mostly as a *base image* for configuring, with Ansible, other software stack on some specified Linux distribution.
39
40 Take 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:
41
42 ```ruby
43 # Vagrantfile
44
45 Vagrant.configure(2) do |config|
46
47 # ==> Choose a Vagrant box to emulate Linux distribution...
48 config.vm.box = "ubuntu/trusty64"
49 #config.vm.box = "hashicorp/precise64"
50 #config.vm.box = "chef/debian-7.8"
51
52 # ==> Executing Ansible...
53 config.vm.provision "ansible" do |ansible|
54 ansible.playbook = "playbook.yml"
55 end
56
57 end
58 ```
59
60 Virtual machines can emulate a variety of Linux distributions, at the cost of runtime overhead.
61
62 Docker 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:
63
64
65 ```dockerfile
66 # Dockerfile
67
68 # ==> Choose a base image to emulate Linux distribution...
69 FROM williamyeh/ansible:ubuntu14.04
70 #FROM williamyeh/ansible:ubuntu12.04
71 #FROM williamyeh/ansible:debian7
72
73 # ==> Copying Ansible playbook...
74 WORKDIR /tmp
75 COPY . /tmp
76
77 # ==> Creating inventory file...
78 RUN echo localhost > inventory
79
80 # ==> Executing Ansible...
81 RUN ansible-playbook -i inventory playbook.yml \
82 --connection=local --sudo
83 ```
84
85 With 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!
86
87
88
89 ## License
90
91 Author: William Yeh <william.pjyeh@gmail.com>
92
93 Licensed under the Apache License V2.0. See the [LICENSE file](LICENSE) for details.