X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=README.md;h=98db6eaf84eeb159e9371e8b39139d6fce452c14;hb=aa3cb4d5e3a74a02a65b4b350251085e47d5eea4;hp=c303044380f93b797bd097ec27451e2ed777d6b1;hpb=9a0d65e426fe6921b1da3c4cb4e76eb390c39b1c;p=github%2Ffretlink%2Fdocker-ansible.git diff --git a/README.md b/README.md index c303044..98db6ea 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ Docker-Ansible base images =================== +[![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) + ## Summary @@ -14,9 +16,62 @@ This repository contains Dockerized [Ansible](https://github.com/ansible/ansible These are Docker images for [Ansible](https://github.com/ansible/ansible) software, installed in a selected Linux distributions. -- OS: Debian (wheezy), Ubuntu (precise, trusty). +- OS: Debian (jessie, wheezy), Ubuntu (trusty, precise), CentOS (7, 6) + +- Ansible: usually the latest version (I didn't pin any specific version). + + +## Images and tags + +- Normal series: + + - `williamyeh/ansible:debian8` + - `williamyeh/ansible:debian7` + - `williamyeh/ansible:ubuntu14.04` + - `williamyeh/ansible:ubuntu12.04` + - `williamyeh/ansible:centos7` + - `williamyeh/ansible:centos6` + +- Onbuild series: + + - `williamyeh/ansible:debian8-onbuild` + - `williamyeh/ansible:debian7-onbuild` + - `williamyeh/ansible:ubuntu14.04-onbuild` + - `williamyeh/ansible:ubuntu12.04-onbuild` + - `williamyeh/ansible:centos7-onbuild` + - `williamyeh/ansible:centos6-onbuild` + + +## For the impatient + +Here comes a simplest working example for the impatient. + +First, choose a base image you'd like to begin with. For example, `williamyeh/ansible:ubuntu14.04-onbuild`. + +Second, put the following `Dockerfile` along with your playbook directory: + +``` +FROM williamyeh/ansible:ubuntu14.04-onbuild + +# ==> Specify requirements filename; default = "requirements.yml" +#ENV REQUIREMENTS requirements.yml + +# ==> Specify playbook filename; default = "playbook.yml" +#ENV PLAYBOOK playbook.yml + +# ==> Specify inventory filename; default = "/etc/ansible/hosts" +#ENV INVENTORY inventory.ini + +# ==> Executing Ansible... +RUN ansible-playbook-wrapper +``` + +Third, `docker build .` + +Done! + +For more advanced usage, the role in Ansible Galaxy [`williamyeh/nginx`](https://galaxy.ansible.com/list#/roles/2245) 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. -- Ansible: usually the latest version. @@ -32,12 +87,30 @@ In the beginning I used the [`ansible/ansible-docker-base`](https://github.com/a Therefore, I built these Docker images on my own. +**NOTE:** [`ansible/ansible-docker-base`](https://github.com/ansible/ansible-docker-base) announced in September 2015: “Ansible no longer maintains images in Dockerhub directly.” + +### Comparison: image size + +``` +REPOSITORY TAG VIRTUAL SIZE +--------------------------- ------------------- ------------ +ansible/centos7-ansible stable 367.5 MB +ansible/ubuntu14.04-ansible stable 286.6 MB + +williamyeh/ansible centos6-onbuild 264.2 MB +williamyeh/ansible centos7-onbuild 275.3 MB +williamyeh/ansible debian7-onbuild 134.4 MB +williamyeh/ansible debian8-onbuild 178.3 MB +williamyeh/ansible ubuntu12.04-onbuild 181.9 MB +williamyeh/ansible ubuntu14.04-onbuild 238.3 MB +``` + ## Usage -Used mostly as a *base image* for configuring, with Ansible, other software stack on some specified Linux distribution. +Used mostly as a *base image* for configuring other software stack on some specified Linux distribution(s). -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: +Take 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: ```ruby # Vagrantfile @@ -48,6 +121,9 @@ Vagrant.configure(2) do |config| config.vm.box = "ubuntu/trusty64" #config.vm.box = "hashicorp/precise64" #config.vm.box = "chef/debian-7.8" + #config.vm.box = "chef/centos-7.0" + #config.vm.box = "chef/centos-6.6" + # ==> Executing Ansible... config.vm.provision "ansible" do |ansible| @@ -57,7 +133,8 @@ Vagrant.configure(2) do |config| end ``` -Virtual machines can emulate a variety of Linux distributions, at the cost of runtime overhead. +Virtual machines can emulate a variety of Linux distributions with good quality, at the cost of runtime overhead. + 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: @@ -68,7 +145,11 @@ Docker to be a rescue. Now, with these **williamyeh/ansible** series, we may tes # ==> Choose a base image to emulate Linux distribution... FROM williamyeh/ansible:ubuntu14.04 #FROM williamyeh/ansible:ubuntu12.04 +#FROM williamyeh/ansible:debian8 #FROM williamyeh/ansible:debian7 +#FROM williamyeh/ansible:centos7 +#FROM williamyeh/ansible:centos6 + # ==> Copying Ansible playbook... WORKDIR /tmp @@ -82,8 +163,39 @@ RUN ansible-playbook -i inventory playbook.yml \ --connection=local --sudo ``` +Or, more simple with `onbuild` series: + +```dockerfile +# Dockerfile + +# ==> Choose a base image to emulate Linux distribution... +FROM williamyeh/ansible:ubuntu14.04-onbuild +#FROM williamyeh/ansible:ubuntu12.04-onbuild +#FROM williamyeh/ansible:debian8-onbuild +#FROM williamyeh/ansible:debian7-onbuild +#FROM williamyeh/ansible:centos7-onbuild +#FROM williamyeh/ansible:centos6-onbuild + + +# ==> Specify requirements filename; default = "requirements.yml" +#ENV REQUIREMENTS requirements.yml + +# ==> Specify playbook filename; default = "playbook.yml" +#ENV PLAYBOOK playbook.yml + +# ==> Specify inventory filename; default = "/etc/ansible/hosts" +#ENV INVENTORY inventory.ini + +# ==> Executing Ansible... +RUN ansible-playbook-wrapper +``` + + + 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! +If better OS emulation (virtualization) isn't required, the Docker approach (containerization) should give you a more efficient Ansible experience. + ## License