• Stars
    star
    400
  • Rank 107,843 (Top 3 %)
  • Language
    Dockerfile
  • License
    Apache License 2.0
  • Created over 9 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Docker images for Ansible software, installed in a selected Linux distributions (Debian/Ubuntu/CentOS/Alpine).

Docker-Ansible base images

Circle CI Build Status

Summary

Repository name in Docker Hub: williamyeh/ansible

This repository contains Dockerized Ansible, published to the public Docker Hub via automated build mechanism.

Configuration

These are Docker images for Ansible software, installed in a selected Linux distributions.

Base OS

Debian (stretch, jessie), Ubuntu (bionic, xenial, trusty), CentOS (7), Alpine (3).

Supports for Wheezy, Precise, and CentOS6 have been ended since Sep 2017.

Ansible

Four versions are provided:

  1. provides the most recent stable version of Ansible; suitable for most people.
  2. same as stable version, but is designed for building (near-)minimal images out of playbooks; i.e., the Ansible body will be removed when mission completed. Refer to β€œBuild Docker images with Ansible: A half-blood approach” for working examples and slides.
  3. provides the old 1.9 version of Ansible (but will be retired someday).
  4. provides the experimental version of Ansible; i.e., the master branch of official Ansible's git repo.

Each version is further divided into two variants:

  • Normal variant: intended to be used as Ansible control machines, or in cases that is inadequate in the onbuild variants.
  • Onbuild variant: intended to be used to build Docker images.

Images and tags

Stable version (installed from official PyPI repo):

  • Normal variants:

    • williamyeh/ansible:debian9
    • williamyeh/ansible:debian8
    • williamyeh/ansible:ubuntu18.04
    • williamyeh/ansible:ubuntu16.04
    • williamyeh/ansible:ubuntu14.04
    • williamyeh/ansible:centos7
    • williamyeh/ansible:alpine3
  • Onbuild variants (recommended for common cases):

    • williamyeh/ansible:debian9-onbuild
    • williamyeh/ansible:debian8-onbuild
    • williamyeh/ansible:ubuntu18.04-onbuild
    • williamyeh/ansible:ubuntu16.04-onbuild
    • williamyeh/ansible:ubuntu14.04-onbuild
    • williamyeh/ansible:centos7-onbuild
    • williamyeh/ansible:alpine3-onbuild

Minimal configuration (the Ansible body will be removed when mission completed):

Refer to β€œBuild Docker images with Ansible: A half-blood approach” for working examples and slides.

  • Onbuild variants:

    • williamyeh/ansible:mini-alpine3
    • williamyeh/ansible:mini-debian9
    • williamyeh/ansible:mini-debian8

Old 1.9 version (will be retired someday):

Note: Ansible 1.9 was not supported in CentOS EPEL since January 2017, according to this announcement.

  • Normal variants:

    • williamyeh/ansible:1.9-debian8
    • williamyeh/ansible:1.9-ubuntu14.04
    • williamyeh/ansible:1.9-alpine3
  • Onbuild variants (recommended for common cases):

    • williamyeh/ansible:1.9-debian8-onbuild
    • williamyeh/ansible:1.9-ubuntu14.04-onbuild
    • williamyeh/ansible:1.9-alpine3-onbuild

Experimental version (building directly from the git master source tree; use at your own risk!):

  • Normal variants:

    • williamyeh/ansible:master-debian9
    • williamyeh/ansible:master-debian8
    • williamyeh/ansible:master-ubuntu18.04
    • williamyeh/ansible:master-ubuntu16.04
    • williamyeh/ansible:master-centos7
  • Onbuild variants (recommended for common cases):

    • williamyeh/ansible:master-debian9-onbuild
    • williamyeh/ansible:master-debian8-onbuild
    • williamyeh/ansible:master-ubuntu18.04-onbuild
    • williamyeh/ansible:master-ubuntu16.04-onbuild
    • williamyeh/ansible:master-centos7-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:ubuntu16.04-onbuild.

Second, put the following Dockerfile along with your playbook directory:

FROM williamyeh/ansible:ubuntu16.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 (with a simple wrapper)...
RUN ansible-playbook-wrapper

Third, docker build .

Done!

For more advanced usage, the role in Ansible Galaxy williamyeh/nginx demonstrates how to perform a simple smoke test (configuration needs test, too!) on a variety of (containerized) Linux distributions on CircleCI's Ubuntu 12.04 and Travis CI’s Ubuntu 14.04 worker instances.

Why yet another Ansible image for Docker?

There has been quite a few Ansible images for Docker (e.g., search in the Docker Hub), so why reinvent the wheel?

In the beginning I used the ansible/ansible-docker-base created by Ansible Inc. It worked well, but left some room for improvement:

  • Base OS image - It provides only centos:centos7 and ubuntu:14.04. Insufficent for me.

  • 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.

Therefore, I built these Docker images on my own.

NOTE: 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            alpine3-onbuild        66.4 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 other software stack on some specified Linux distribution(s).

Take Debian/Ubuntu/CentOS for example. To test an Ansible playbook.yml against a variety of Linux distributions, we may use Vagrant as follows:

# Vagrantfile

Vagrant.configure(2) do |config|

    # ==> Choose a Vagrant box to emulate Linux distribution...
    config.vm.box = "ubuntu/xenial64"
    #config.vm.box = "ubuntu/trusty64"
    #config.vm.box = "debian/stretch64"
    #config.vm.box = "debian/jessie64"
    #config.vm.box = "bento/centos-7.2"
    #config.vm.box = "maier/alpine-3.3.1-x86_64"


    # ==> Executing Ansible...
    config.vm.provision "ansible" do |ansible|
        ansible.playbook = "playbook.yml"
    end

end

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:

# Dockerfile

# ==> Choose a base image to emulate Linux distribution...
FROM williamyeh/ansible:ubuntu16.04
#FROM williamyeh/ansible:ubuntu14.04
#FROM williamyeh/ansible:debian9
#FROM williamyeh/ansible:debian8
#FROM williamyeh/ansible:centos7
#FROM williamyeh/ansible:alpine3


# ==> Copying Ansible playbook...
WORKDIR /tmp
COPY  .  /tmp

# ==> Creating inventory file...
RUN echo localhost > inventory

# ==> Executing Ansible...
RUN ansible-playbook -i inventory playbook.yml \
      --connection=local --sudo

You may also work with onbuild variants, which take care of many routine steps for you:

# Dockerfile

# ==> Choose a base image to emulate Linux distribution...
FROM williamyeh/ansible:ubuntu16.04-onbuild
#FROM williamyeh/ansible:ubuntu14.04-onbuild
#FROM williamyeh/ansible:debian9-onbuild
#FROM williamyeh/ansible:debian8-onbuild
#FROM williamyeh/ansible:centos7-onbuild
#FROM williamyeh/ansible:alpine3-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 (with a simple wrapper)...
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

Author: William Yeh [email protected]

Licensed under the Apache License V2.0. See the LICENSE file for details.

More Repositories

1

ansible-prometheus

An Ansible role that installs Prometheus, in the format for Ansible Galaxy.
Shell
259
star
2

docker-workshop

Slides and lab materials for my Docker Workshop (in Traditional Chinese).
Shell
188
star
3

ansible-oracle-java

An Ansible role that installs Oracle JDK, in the format for Ansible Galaxy.
Shell
170
star
4

docker-enabled-vagrant

Docker-enabled Vagrant boxes for Ubuntu 14.04, Debian 8, and CentOS 7
Shell
137
star
5

docker-wrk

A minimal wrk image for Docker - Modern HTTP benchmarking tool.
Dockerfile
55
star
6

docker-mini

Quest for minimal Docker images: slides and lab materials.
Shell
40
star
7

ansible-fluentd

An Ansible role that installs Fluentd, in the format for Ansible Galaxy
39
star
8

docker-java8

Oracle Java 8 image for Docker
26
star
9

build-docker-with-ansible

Build Docker images with Ansible - A half-blood approach
Shell
26
star
10

ansible-tutorial

A Gentle Introduction to Ansible: lab materials.
Ruby
25
star
11

ansible-nginx

An Ansible role that installs Nginx, in the format for Ansible Galaxy.
Shell
23
star
12

jcconf2014-docker

Demo files for Docker speech on JCConf Taiwan 2014
Shell
23
star
13

docker-java7

Oracle Java 7 image for Docker
19
star
14

practical-ansible

Practical Ansible: A Top-down Introduction (Ansible 實戰:Top-down θ§€ι»ž).
Python
17
star
15

extract-elf-so

Extract .so files from specified ELF executables, and pack them in a tarball.
Go
15
star
16

ansible-uwsgi

An Ansible role that installs uWSGI, in the format for Ansible Galaxy
15
star
17

workshop-gcpug201906

Kubernetes hands-on lab for GCPUG Taipei Meetup 2019-06
C#
15
star
18

ansible-nodejs

An Ansible role that installs Node.js, in the format for Ansible Galaxy.
15
star
19

ansible-monit

An Ansible role that installs Monit, in the format for Ansible Galaxy.
Shell
14
star
20

fswatch

fswatch - Watch for changes in file system
Go
13
star
21

workshop-cloud2019

Kubernetes hands-on lab for Taiwan Cloud Edge Summit 2019
C#
13
star
22

ansible-mongodb

An Ansible role that installs MongoDB, in the format for Ansible Galaxy.
Shell
11
star
23

docker-scala

Scala image for Docker (jdk 1.7.0 + Scala)
10
star
24

docker-json-server

A minimal JSON Server image for Docker - Get a full fake REST API with zero coding in less than 30 seconds (seriously)
Dockerfile
10
star
25

configmap-auto-reload

This repo demonstrates 3 ways for apps to auto reload from Kubernetes ConfigMap.
Shell
10
star
26

ansible-vagrantbox

Vagrant Box for Ansible Control Machine.
Shell
9
star
27

docker-behave

Docker image for Python-based SBE/BDD tools
Python
9
star
28

ansible-workshop

Ansible Workshop - Hands-On Materials.
Ruby
7
star
29

remark-zoom

Zoom in/out facility for remark.
CSS
6
star
30

ansible-nvm-nodejs

An Ansible role that installs NVM and Node.js, in the format for Ansible Galaxy (deprecated)
Shell
6
star
31

docker-host-tools

Some handy tools for managing Docker images and containers.
Perl
6
star
32

server-config-template

Simple server configuration template via Ansible & Vagrant.
Shell
5
star
33

docker-sbt

Sbt image for Docker (jdk 1.7.0 + sbt).
Shell
5
star
34

ansible-mongodb-exporter

An Ansible role that installs mongodb_exporter for Prometheus, in the format for Ansible Galaxy.
Shell
5
star
35

ansible-ganglia-monitor

An Ansible role that installs ganglia-monitor (Ganglia Monitoring Daemon, gmond) and modules, in the format for Ansible Galaxy.
Python
5
star
36

workshop-k8s201908

Kubernetes hands-on lab for GDG Cloud KH Meetup #4 (2019-08-11)
C#
4
star
37

docker-word2vec

word2vec image for Docker - Tool for computing continuous distributed representations of words.
Shell
4
star
38

workshop-k8s201909-eks

Kubernetes hands-on lab (EKS version) for Kubernetes Summit (2019-09-11)
C#
4
star
39

docker-fluentd

Docker image for Fluentd.
Shell
3
star
40

docker-dash

Docker image for static DASH (β€œthe Debian Almquist Shell”) without GPLv2 parts.
C
3
star
41

vag2inv

vag2inv (Vagrant to Inventory): Generate Ansible inventory file by investigating runtime information from a set of running Vagrant boxes.
Go
3
star
42

ansible-reset-locale

An Ansible role that resets locale, in the format for Ansible Galaxy
3
star
43

nodejs-redis-example

A simple web server (written in Node.js) that generates dyanmic content based on responses from Redis.
JavaScript
2
star
44

test-travisci-trusty

Test Travis CI with Trusty VM
2
star
45

docker-boom

A minimal Docker image for boom - HTTP(S) load generator, ApacheBench (ab) replacement, written in Go.
2
star
46

ansible-docker-tools

An Ansible role that installs common tools for Docker, in the format for Ansible Galaxy.
2
star
47

Docker-Spray-HttpServer

A simple Dockerized http server written in Akka + Spray (spray-can) framework
2
star
48

grpcurl-and-ghz-demo

A simple demo for 2 useful gRPC tools: gRPCurl & ghz.
Go
2
star
49

ansible-monit-tarball

Tarballs for Ansible Monit
1
star
50

grpc-lb

gRPC Load Balancing Demo
Go
1
star
51

docker-python2

Python 2 image for Docker
1
star
52

readiness-probes-and-zero-downtime

Demonstrate how readiness probes affect the zero downtime behavior in Kubernetes
Go
1
star
53

idempotency-key-test

Idempotency Key Performance Test
Go
1
star
54

ansible-pcp

An Ansible role that installs PCP (Performance Co-Pilot), in the format for Ansible Galaxy.
Python
1
star
55

ansible-git-deploy-demo

Demo for using Git in Ansible
Ruby
1
star
56

concise-core

Java
1
star
57

ansible-es-cluster-exporter

An Ansible role that installs Elasticsearch cluster exporter for Prometheus, in the format for Ansible Galaxy.
Shell
1
star
58

ansible-elasticsearch

An Ansible role that installs Elasticsearch, in the format for Ansible Galaxy.
Shell
1
star
59

docker-hey

A minimal Docker image for Hey - HTTP(S) load generator, ApacheBench (ab) replacement, written in Go.
Dockerfile
1
star
60

blackbox-exporter-demo

A simple demo for Blackbox exporter
1
star