aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--README.md49
-rw-r--r--Vagrantfile7
-rw-r--r--debian7-onbuild/Dockerfile47
-rwxr-xr-xdebian7-onbuild/ansible-playbook-wrapper30
-rw-r--r--debian7/Dockerfile8
-rw-r--r--debian8-onbuild/Dockerfile47
-rwxr-xr-xdebian8-onbuild/ansible-playbook-wrapper30
-rw-r--r--debian8/Dockerfile39
-rw-r--r--ubuntu12.04-onbuild/Dockerfile43
-rwxr-xr-xubuntu12.04-onbuild/ansible-playbook-wrapper30
-rw-r--r--ubuntu14.04-onbuild/Dockerfile43
-rwxr-xr-xubuntu14.04-onbuild/ansible-playbook-wrapper30
12 files changed, 397 insertions, 6 deletions
diff --git a/README.md b/README.md
index c303044..7dce9f8 100644
--- a/README.md
+++ b/README.md
@@ -14,11 +14,27 @@ This repository contains Dockerized [Ansible](https://github.com/ansible/ansible
14 14
15These are Docker images for [Ansible](https://github.com/ansible/ansible) software, installed in a selected Linux distributions. 15These are Docker images for [Ansible](https://github.com/ansible/ansible) software, installed in a selected Linux distributions.
16 16
17- OS: Debian (wheezy), Ubuntu (precise, trusty). 17- OS: Debian (jessie, wheezy), Ubuntu (trusty, precise).
18 18
19- Ansible: usually the latest version. 19- Ansible: usually the latest version.
20 20
21 21
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`
30
31- onbuild series:
32
33 - `williamyeh/ansible:debian8-onbuild`
34 - `williamyeh/ansible:debian7-onbuild`
35 - `williamyeh/ansible:ubuntu14.04-onbuild`
36 - `williamyeh/ansible:ubuntu12.04-onbuild`
37
22 38
23## Why yet another Ansible image for Docker? 39## Why yet another Ansible image for Docker?
24 40
@@ -57,7 +73,8 @@ Vagrant.configure(2) do |config|
57end 73end
58``` 74```
59 75
60Virtual machines can emulate a variety of Linux distributions, at the cost of runtime overhead. 76Virtual machines can emulate a variety of Linux distributions with good quality, at the cost of runtime overhead.
77
61 78
62Docker 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: 79Docker 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 80
@@ -68,8 +85,10 @@ Docker to be a rescue. Now, with these **williamyeh/ansible** series, we may tes
68# ==> Choose a base image to emulate Linux distribution... 85# ==> Choose a base image to emulate Linux distribution...
69FROM williamyeh/ansible:ubuntu14.04 86FROM williamyeh/ansible:ubuntu14.04
70#FROM williamyeh/ansible:ubuntu12.04 87#FROM williamyeh/ansible:ubuntu12.04
88#FROM williamyeh/ansible:debian8
71#FROM williamyeh/ansible:debian7 89#FROM williamyeh/ansible:debian7
72 90
91
73# ==> Copying Ansible playbook... 92# ==> Copying Ansible playbook...
74WORKDIR /tmp 93WORKDIR /tmp
75COPY . /tmp 94COPY . /tmp
@@ -82,8 +101,34 @@ RUN ansible-playbook -i inventory playbook.yml \
82 --connection=local --sudo 101 --connection=local --sudo
83``` 102```
84 103
104Or, more simple with `onbuild` series:
105
106```dockerfile
107# Dockerfile
108
109# ==> Choose a base image to emulate Linux distribution...
110FROM williamyeh/ansible:ubuntu14.04-onbuild
111#FROM williamyeh/ansible:ubuntu12.04-onbuild
112#FROM williamyeh/ansible:debian8-onbuild
113#FROM williamyeh/ansible:debian7-onbuild
114
115
116# ==> Specify playbook filename; default = "playbook.yml"
117#ENV PLAYBOOK playbook.yml
118
119# ==> Specify inventory filename; default = "/etc/ansible/hosts"
120#ENV INVENTORY inventory.ini
121
122# ==> Executing Ansible...
123RUN ansible-playbook-wrapper
124```
125
126
127
85With 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! 128With 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 129
130If better OS emulation (virtualization) isn't required, the Docker approach (containerization) should give you a more efficient Ansible experience.
131
87 132
88 133
89## License 134## License
diff --git a/Vagrantfile b/Vagrantfile
index b198622..4d8c0a6 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -6,6 +6,13 @@ Vagrant.configure(2) do |config|
6 6
7 docker build -t ansible:ubuntu14.04 ubuntu14.04 7 docker build -t ansible:ubuntu14.04 ubuntu14.04
8 docker build -t ansible:ubuntu12.04 ubuntu12.04 8 docker build -t ansible:ubuntu12.04 ubuntu12.04
9 docker build -t ansible:debian8 debian8
9 docker build -t ansible:debian7 debian7 10 docker build -t ansible:debian7 debian7
11
12 docker build -t ansible:ubuntu14.04-onbuild ubuntu14.04-onbuild
13 docker build -t ansible:ubuntu12.04-onbuild ubuntu12.04-onbuild
14 docker build -t ansible:debian8-onbuild debian8-onbuild
15 docker build -t ansible:debian7-onbuild debian7-onbuild
16
10 SHELL 17 SHELL
11end 18end
diff --git a/debian7-onbuild/Dockerfile b/debian7-onbuild/Dockerfile
new file mode 100644
index 0000000..1620990
--- /dev/null
+++ b/debian7-onbuild/Dockerfile
@@ -0,0 +1,47 @@
1# Dockerfile for building Ansible image for Debian 7 (wheezy), with as few additional software as possible.
2#
3# @see https://launchpad.net/~ansible/+archive/ubuntu/ansible
4#
5# Version 1.0
6#
7
8
9# pull base image
10FROM debian:wheezy
11
12MAINTAINER William Yeh <william.pjyeh@gmail.com>
13
14
15RUN echo "===> Installing python, sudo, and supporting tools..." && \
16 apt-get update && \
17 DEBIAN_FRONTEND=noninteractive \
18 apt-get install -y \
19 python python-yaml sudo \
20 curl gcc python-pip python-dev && \
21 \
22 \
23 echo "===> Installing Ansible..." && \
24 pip install ansible && \
25 \
26 \
27 echo "===> Removing unused APT resources..." && \
28 apt-get -f -y --auto-remove remove curl gcc python-pip python-dev && \
29 apt-get clean && \
30 rm -rf /var/lib/apt/lists/* /tmp/* && \
31 \
32 \
33 echo "===> Adding hosts for convenience..." && \
34 mkdir -p /etc/ansible && \
35 echo '[local]\nlocalhost\n' > /etc/ansible/hosts
36
37
38COPY ansible-playbook-wrapper /usr/local/bin/
39
40ONBUILD RUN DEBIAN_FRONTEND=noninteractive apt-get update
41ONBUILD WORKDIR /tmp
42ONBUILD COPY . /tmp
43
44
45
46# default command: display Ansible version
47CMD [ "ansible-playbook", "--version" ]
diff --git a/debian7-onbuild/ansible-playbook-wrapper b/debian7-onbuild/ansible-playbook-wrapper
new file mode 100755
index 0000000..bf137c8
--- /dev/null
+++ b/debian7-onbuild/ansible-playbook-wrapper
@@ -0,0 +1,30 @@
1#!/bin/sh
2#
3# Simple wrapper for executing ansible-playbook with local connection.
4#
5# USAGE:
6# ansible-playbook-wrapper [other ansible-playbook arguments]
7#
8# ENVIRONMENT VARIABLES:
9#
10# - PLAYBOOK: playbook filename; default = "playbook.yml"
11# - INVENTORY: inventory filename; default = "/etc/ansible/hosts"
12#
13
14
15if [ -z "$PLAYBOOK" ]; then
16 PLAYBOOK=playbook.yml
17fi
18
19
20if [ -z "$INVENTORY" ]; then
21 exec ansible-playbook \
22 $PLAYBOOK \
23 --connection=local \
24 "$@"
25else
26 exec ansible-playbook \
27 -i $INVENTORY $PLAYBOOK \
28 --connection=local \
29 "$@"
30fi
diff --git a/debian7/Dockerfile b/debian7/Dockerfile
index 72d3d31..afa69df 100644
--- a/debian7/Dockerfile
+++ b/debian7/Dockerfile
@@ -14,9 +14,9 @@ MAINTAINER William Yeh <william.pjyeh@gmail.com>
14 14
15RUN echo "===> Installing python, sudo, and supporting tools..." && \ 15RUN echo "===> Installing python, sudo, and supporting tools..." && \
16 apt-get update && \ 16 apt-get update && \
17 DEBIAN_FRONTEND=noninteractive \ 17 DEBIAN_FRONTEND=noninteractive \
18 apt-get install -y \ 18 apt-get install -y \
19 python sudo \ 19 python python-yaml sudo \
20 curl gcc python-pip python-dev && \ 20 curl gcc python-pip python-dev && \
21 \ 21 \
22 \ 22 \
@@ -27,7 +27,7 @@ RUN echo "===> Installing python, sudo, and supporting tools..." && \
27 echo "===> Removing unused APT resources..." && \ 27 echo "===> Removing unused APT resources..." && \
28 apt-get -f -y --auto-remove remove curl gcc python-pip python-dev && \ 28 apt-get -f -y --auto-remove remove curl gcc python-pip python-dev && \
29 apt-get clean && \ 29 apt-get clean && \
30 rm -rf /var/lib/apt/lists/* && \ 30 rm -rf /var/lib/apt/lists/* /tmp/* && \
31 \ 31 \
32 \ 32 \
33 echo "===> Adding hosts for convenience..." && \ 33 echo "===> Adding hosts for convenience..." && \
diff --git a/debian8-onbuild/Dockerfile b/debian8-onbuild/Dockerfile
new file mode 100644
index 0000000..04eadb5
--- /dev/null
+++ b/debian8-onbuild/Dockerfile
@@ -0,0 +1,47 @@
1# Dockerfile for building Ansible image for Debian 8 (jessie), with as few additional software as possible.
2#
3# @see https://launchpad.net/~ansible/+archive/ubuntu/ansible
4#
5# Version 1.0
6#
7
8
9# pull base image
10FROM debian:jessie
11
12MAINTAINER William Yeh <william.pjyeh@gmail.com>
13
14
15RUN echo "===> Installing python, sudo, and supporting tools..." && \
16 apt-get update && \
17 DEBIAN_FRONTEND=noninteractive \
18 apt-get install -y \
19 python python-yaml sudo \
20 curl gcc python-pip python-dev && \
21 \
22 \
23 echo "===> Installing Ansible..." && \
24 pip install ansible && \
25 \
26 \
27 echo "===> Removing unused APT resources..." && \
28 apt-get -f -y --auto-remove remove curl gcc python-pip python-dev && \
29 apt-get clean && \
30 rm -rf /var/lib/apt/lists/* /tmp/* && \
31 \
32 \
33 echo "===> Adding hosts for convenience..." && \
34 mkdir -p /etc/ansible && \
35 echo '[local]\nlocalhost\n' > /etc/ansible/hosts
36
37
38COPY ansible-playbook-wrapper /usr/local/bin/
39
40ONBUILD RUN DEBIAN_FRONTEND=noninteractive apt-get update
41ONBUILD WORKDIR /tmp
42ONBUILD COPY . /tmp
43
44
45
46# default command: display Ansible version
47CMD [ "ansible-playbook", "--version" ]
diff --git a/debian8-onbuild/ansible-playbook-wrapper b/debian8-onbuild/ansible-playbook-wrapper
new file mode 100755
index 0000000..bf137c8
--- /dev/null
+++ b/debian8-onbuild/ansible-playbook-wrapper
@@ -0,0 +1,30 @@
1#!/bin/sh
2#
3# Simple wrapper for executing ansible-playbook with local connection.
4#
5# USAGE:
6# ansible-playbook-wrapper [other ansible-playbook arguments]
7#
8# ENVIRONMENT VARIABLES:
9#
10# - PLAYBOOK: playbook filename; default = "playbook.yml"
11# - INVENTORY: inventory filename; default = "/etc/ansible/hosts"
12#
13
14
15if [ -z "$PLAYBOOK" ]; then
16 PLAYBOOK=playbook.yml
17fi
18
19
20if [ -z "$INVENTORY" ]; then
21 exec ansible-playbook \
22 $PLAYBOOK \
23 --connection=local \
24 "$@"
25else
26 exec ansible-playbook \
27 -i $INVENTORY $PLAYBOOK \
28 --connection=local \
29 "$@"
30fi
diff --git a/debian8/Dockerfile b/debian8/Dockerfile
new file mode 100644
index 0000000..c49558a
--- /dev/null
+++ b/debian8/Dockerfile
@@ -0,0 +1,39 @@
1# Dockerfile for building Ansible image for Debian 8 (jessie), with as few additional software as possible.
2#
3# @see https://launchpad.net/~ansible/+archive/ubuntu/ansible
4#
5# Version 1.0
6#
7
8
9# pull base image
10FROM debian:jessie
11
12MAINTAINER William Yeh <william.pjyeh@gmail.com>
13
14
15RUN echo "===> Installing python, sudo, and supporting tools..." && \
16 apt-get update && \
17 DEBIAN_FRONTEND=noninteractive \
18 apt-get install -y \
19 python python-yaml sudo \
20 curl gcc python-pip python-dev && \
21 \
22 \
23 echo "===> Installing Ansible..." && \
24 pip install ansible && \
25 \
26 \
27 echo "===> Removing unused APT resources..." && \
28 apt-get -f -y --auto-remove remove curl gcc python-pip python-dev && \
29 apt-get clean && \
30 rm -rf /var/lib/apt/lists/* /tmp/* && \
31 \
32 \
33 echo "===> Adding hosts for convenience..." && \
34 mkdir -p /etc/ansible && \
35 echo '[local]\nlocalhost\n' > /etc/ansible/hosts
36
37
38# default command: display Ansible version
39CMD [ "ansible-playbook", "--version" ]
diff --git a/ubuntu12.04-onbuild/Dockerfile b/ubuntu12.04-onbuild/Dockerfile
new file mode 100644
index 0000000..f7a5aa0
--- /dev/null
+++ b/ubuntu12.04-onbuild/Dockerfile
@@ -0,0 +1,43 @@
1# Dockerfile for building Ansible image for Ubuntu 12.04 (presice), with as few additional software as possible.
2#
3# @see https://launchpad.net/~ansible/+archive/ubuntu/ansible
4#
5# Version 1.0
6#
7
8
9# pull base image
10FROM ubuntu:12.04
11
12MAINTAINER William Yeh <william.pjyeh@gmail.com>
13
14
15RUN echo "===> Adding Ansible's PPA..." && \
16 echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu precise main" | tee /etc/apt/sources.list.d/ansible.list && \
17 echo "deb-src http://ppa.launchpad.net/ansible/ansible/ubuntu precise main" | tee -a /etc/apt/sources.list.d/ansible.list && \
18 apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 7BB9C367 && \
19 DEBIAN_FRONTEND=noninteractive apt-get update && \
20 \
21 \
22 echo "===> Installing Ansible (and sudo)..." && \
23 apt-get install -y ansible sudo && \
24 \
25 \
26 echo "===> Removing Ansible PPA..." && \
27 rm -rf /var/lib/apt/lists/* /etc/apt/sources.list.d/ansible.list && \
28 \
29 \
30 echo "===> Adding hosts for convenience..." && \
31 echo '[local]\nlocalhost\n' > /etc/ansible/hosts
32
33
34COPY ansible-playbook-wrapper /usr/local/bin/
35
36ONBUILD RUN DEBIAN_FRONTEND=noninteractive apt-get update
37ONBUILD WORKDIR /tmp
38ONBUILD COPY . /tmp
39
40
41
42# default command: display Ansible version
43CMD [ "ansible-playbook", "--version" ]
diff --git a/ubuntu12.04-onbuild/ansible-playbook-wrapper b/ubuntu12.04-onbuild/ansible-playbook-wrapper
new file mode 100755
index 0000000..bf137c8
--- /dev/null
+++ b/ubuntu12.04-onbuild/ansible-playbook-wrapper
@@ -0,0 +1,30 @@
1#!/bin/sh
2#
3# Simple wrapper for executing ansible-playbook with local connection.
4#
5# USAGE:
6# ansible-playbook-wrapper [other ansible-playbook arguments]
7#
8# ENVIRONMENT VARIABLES:
9#
10# - PLAYBOOK: playbook filename; default = "playbook.yml"
11# - INVENTORY: inventory filename; default = "/etc/ansible/hosts"
12#
13
14
15if [ -z "$PLAYBOOK" ]; then
16 PLAYBOOK=playbook.yml
17fi
18
19
20if [ -z "$INVENTORY" ]; then
21 exec ansible-playbook \
22 $PLAYBOOK \
23 --connection=local \
24 "$@"
25else
26 exec ansible-playbook \
27 -i $INVENTORY $PLAYBOOK \
28 --connection=local \
29 "$@"
30fi
diff --git a/ubuntu14.04-onbuild/Dockerfile b/ubuntu14.04-onbuild/Dockerfile
new file mode 100644
index 0000000..c0e400f
--- /dev/null
+++ b/ubuntu14.04-onbuild/Dockerfile
@@ -0,0 +1,43 @@
1# Dockerfile for building Ansible image for Ubuntu 14.04 (trusty), with as few additional software as possible.
2#
3# @see https://launchpad.net/~ansible/+archive/ubuntu/ansible
4#
5# Version 1.0
6#
7
8
9# pull base image
10FROM ubuntu:14.04
11
12MAINTAINER William Yeh <william.pjyeh@gmail.com>
13
14
15RUN echo "===> Adding Ansible's PPA..." && \
16 echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main" | tee /etc/apt/sources.list.d/ansible.list && \
17 echo "deb-src http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main" | tee -a /etc/apt/sources.list.d/ansible.list && \
18 apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 7BB9C367 && \
19 DEBIAN_FRONTEND=noninteractive apt-get update && \
20 \
21 \
22 echo "===> Installing Ansible..." && \
23 apt-get install -y ansible && \
24 \
25 \
26 echo "===> Removing Ansible PPA..." && \
27 rm -rf /var/lib/apt/lists/* /etc/apt/sources.list.d/ansible.list && \
28 \
29 \
30 echo "===> Adding hosts for convenience..." && \
31 echo '[local]\nlocalhost\n' > /etc/ansible/hosts
32
33
34COPY ansible-playbook-wrapper /usr/local/bin/
35
36ONBUILD RUN DEBIAN_FRONTEND=noninteractive apt-get update
37ONBUILD WORKDIR /tmp
38ONBUILD COPY . /tmp
39
40
41
42# default command: display Ansible version
43CMD [ "ansible-playbook", "--version" ]
diff --git a/ubuntu14.04-onbuild/ansible-playbook-wrapper b/ubuntu14.04-onbuild/ansible-playbook-wrapper
new file mode 100755
index 0000000..bf137c8
--- /dev/null
+++ b/ubuntu14.04-onbuild/ansible-playbook-wrapper
@@ -0,0 +1,30 @@
1#!/bin/sh
2#
3# Simple wrapper for executing ansible-playbook with local connection.
4#
5# USAGE:
6# ansible-playbook-wrapper [other ansible-playbook arguments]
7#
8# ENVIRONMENT VARIABLES:
9#
10# - PLAYBOOK: playbook filename; default = "playbook.yml"
11# - INVENTORY: inventory filename; default = "/etc/ansible/hosts"
12#
13
14
15if [ -z "$PLAYBOOK" ]; then
16 PLAYBOOK=playbook.yml
17fi
18
19
20if [ -z "$INVENTORY" ]; then
21 exec ansible-playbook \
22 $PLAYBOOK \
23 --connection=local \
24 "$@"
25else
26 exec ansible-playbook \
27 -i $INVENTORY $PLAYBOOK \
28 --connection=local \
29 "$@"
30fi