aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorWilliam Yeh <william.pjyeh@gmail.com>2016-06-02 16:07:46 +0800
committerWilliam Yeh <william.pjyeh@gmail.com>2016-06-02 16:07:46 +0800
commit042ddec8383b0755e60bb01dc93ae3378374b637 (patch)
tree2bf2051dbe6a8143a981528297b6a462c4a2cb37
parentf966242805e67f91bffdc5f9eb02096bb5e1f856 (diff)
downloaddocker-ansible-042ddec8383b0755e60bb01dc93ae3378374b637.tar.gz
docker-ansible-042ddec8383b0755e60bb01dc93ae3378374b637.tar.zst
docker-ansible-042ddec8383b0755e60bb01dc93ae3378374b637.zip
Add: `mini-debian8` tag.
-rw-r--r--.travis.yml10
-rw-r--r--README.md1
-rw-r--r--circle.yml10
-rw-r--r--mini-debian8/Dockerfile27
-rwxr-xr-xmini-debian8/ansible-playbook-wrapper49
-rw-r--r--mini-debian8/apt-list18
-rwxr-xr-xmini-debian8/install-ansible.sh31
-rwxr-xr-xmini-debian8/prepare-pkg-list.sh37
-rwxr-xr-xmini-debian8/uninstall-ansible.sh21
-rw-r--r--mini-test/Dockerfile.alpine32
-rw-r--r--mini-test/Dockerfile.debian814
-rw-r--r--mini-test/playbook.yml19
12 files changed, 229 insertions, 10 deletions
diff --git a/.travis.yml b/.travis.yml
index ea6cc78..ac9983b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -59,8 +59,10 @@ before_install:
59 - docker build -t ansible_master_centos6_onbuild master-centos6-onbuild 59 - docker build -t ansible_master_centos6_onbuild master-centos6-onbuild
60 60
61 61
62 - docker build -t ansible_mini_apline3 mini-alpine3 62 - docker build -t ansible_mini_alpine3 mini-alpine3
63 - docker build -t nginx_apline3 -f mini-test/Dockerfile.alpine3 mini-test 63 - docker build -t ansible_mini_debian8 mini-debian8
64 - docker build -t nginx_alpine3 -f mini-test/Dockerfile.alpine3 mini-test
65 - docker build -t nginx_debian8 -f mini-test/Dockerfile.debian8 mini-test
64 66
65 67
66script: 68script:
@@ -114,7 +116,8 @@ script:
114 - docker run -i ansible_master_centos6_onbuild > result-master-centos6-onbuild 116 - docker run -i ansible_master_centos6_onbuild > result-master-centos6-onbuild
115 117
116 118
117 - docker run -i nginx_apline3 2> result-nginx-alpine3 119 - docker run -i nginx_alpine3 2> result-nginx-alpine3
120 - docker run -i nginx_debian8 2> result-nginx-debian8
118 121
119 122
120 - echo "==> Validating the test results..." 123 - echo "==> Validating the test results..."
@@ -166,3 +169,4 @@ script:
166 - sh -c "[ -s result-master-centos6-onbuild ]" 169 - sh -c "[ -s result-master-centos6-onbuild ]"
167 170
168 - sh -c "[ -s result-nginx-alpine3 ]" 171 - sh -c "[ -s result-nginx-alpine3 ]"
172 - sh -c "[ -s result-nginx-debian8 ]"
diff --git a/README.md b/README.md
index 8abe0cc..d982543 100644
--- a/README.md
+++ b/README.md
@@ -102,6 +102,7 @@ These are Docker images for [Ansible](https://github.com/ansible/ansible) softwa
102- Onbuild series: 102- Onbuild series:
103 103
104 - `williamyeh/ansible:mini-alpine3` 104 - `williamyeh/ansible:mini-alpine3`
105 - `williamyeh/ansible:mini-debian8`
105 106
106 107
107 108
diff --git a/circle.yml b/circle.yml
index 9fc121f..18e5253 100644
--- a/circle.yml
+++ b/circle.yml
@@ -60,8 +60,10 @@ dependencies:
60 - docker build -t ansible_master_centos6_onbuild master-centos6-onbuild 60 - docker build -t ansible_master_centos6_onbuild master-centos6-onbuild
61 61
62 62
63 - docker build -t ansible_mini_apline3 mini-alpine3 63 - docker build -t ansible_mini_alpine3 mini-alpine3
64 - docker build -t nginx_apline3 -f mini-test/Dockerfile.alpine3 mini-test 64 - docker build -t ansible_mini_debian8 mini-debian8
65 - docker build -t nginx_alpine3 -f mini-test/Dockerfile.alpine3 mini-test
66 - docker build -t nginx_debian8 -f mini-test/Dockerfile.debian8 mini-test
65 67
66 68
67test: 69test:
@@ -116,7 +118,8 @@ test:
116 - docker run -i ansible_master_centos6_onbuild > result-master-centos6-onbuild 118 - docker run -i ansible_master_centos6_onbuild > result-master-centos6-onbuild
117 119
118 120
119 - docker run -i nginx_apline3 2> result-nginx-alpine3 121 - docker run -i nginx_alpine3 2> result-nginx-alpine3
122 - docker run -i nginx_debian8 2> result-nginx-debian8
120 123
121 124
122 - echo "==> Validating the test results..." 125 - echo "==> Validating the test results..."
@@ -168,3 +171,4 @@ test:
168 - sh -c "[ -s result-master-centos6-onbuild ]" 171 - sh -c "[ -s result-master-centos6-onbuild ]"
169 172
170 - sh -c "[ -s result-nginx-alpine3 ]" 173 - sh -c "[ -s result-nginx-alpine3 ]"
174 - sh -c "[ -s result-nginx-debian8 ]"
diff --git a/mini-debian8/Dockerfile b/mini-debian8/Dockerfile
new file mode 100644
index 0000000..d45d4e6
--- /dev/null
+++ b/mini-debian8/Dockerfile
@@ -0,0 +1,27 @@
1# Dockerfile for building Debian-based image, via Ansible playbooks.
2#
3# @see http://docs.ansible.com/ansible/intro_installation.html#running-from-source
4#
5# Version 1.0
6#
7
8
9# pull base image
10FROM debian:8
11
12MAINTAINER William Yeh <william.pjyeh@gmail.com>
13
14#ENV APT_LIST apt-list
15
16
17COPY . /tmp
18
19ONBUILD COPY . /tmp
20ONBUILD RUN \
21 cd /tmp && \
22 ./prepare-pkg-list.sh && \
23 ./install-ansible.sh && \
24 ./ansible-playbook-wrapper && \
25 ./uninstall-ansible.sh && \
26 cd / && \
27 rm -rf /tmp/* \ No newline at end of file
diff --git a/mini-debian8/ansible-playbook-wrapper b/mini-debian8/ansible-playbook-wrapper
new file mode 100755
index 0000000..0ba45e6
--- /dev/null
+++ b/mini-debian8/ansible-playbook-wrapper
@@ -0,0 +1,49 @@
1#!/bin/sh
2#
3# Simple wrapper for executing ansible-galaxy and ansible-playbook
4# with local connection.
5#
6# USAGE:
7# ansible-playbook-wrapper [other ansible-playbook arguments]
8#
9# ENVIRONMENT VARIABLES:
10#
11# - REQUIREMENTS: requirements filename; default = "requirements.yml"
12# - PLAYBOOK: playbook filename; default = "playbook.yml"
13# - INVENTORY: inventory filename; default = "/etc/ansible/hosts"
14#
15
16
17#
18# install Galaxy roles, if any
19#
20
21if [ -z "$REQUIREMENTS" ]; then
22 REQUIREMENTS=requirements.yml
23fi
24
25if [ -f "$REQUIREMENTS" ]; then
26 ansible-galaxy install -r $REQUIREMENTS
27fi
28
29
30#
31# execute playbook
32#
33
34if [ -z "$PLAYBOOK" ]; then
35 PLAYBOOK=playbook.yml
36fi
37
38
39if [ -z "$INVENTORY" ]; then
40 exec ansible-playbook \
41 $PLAYBOOK \
42 --connection=local \
43 "$@"
44else
45 exec ansible-playbook \
46 -i $INVENTORY $PLAYBOOK \
47 --connection=local \
48 "$@"
49fi
diff --git a/mini-debian8/apt-list b/mini-debian8/apt-list
new file mode 100644
index 0000000..635e7d5
--- /dev/null
+++ b/mini-debian8/apt-list
@@ -0,0 +1,18 @@
1#
2# packages to be installed via APT;
3# lines beginning with "! " (an exclamation mark, followed by a space) will *not* be *uninstalled* afterwards.
4#
5
6
7# common
8#####sudo curl gcc
9
10# ssl
11#####openssl ca-certificates
12
13# python-runtime
14python
15#####python-pip python-yaml
16
17# build-dependencies
18#####python-dev libffi-dev libssl-dev \ No newline at end of file
diff --git a/mini-debian8/install-ansible.sh b/mini-debian8/install-ansible.sh
new file mode 100755
index 0000000..6ddf0cb
--- /dev/null
+++ b/mini-debian8/install-ansible.sh
@@ -0,0 +1,31 @@
1#!/bin/sh
2#
3# Simple wrapper for installing ansible
4#
5
6
7echo "===> Adding backports..."
8
9mkdir -p /etc/apt/sources.list.d/
10echo "deb http://ftp.debian.org/debian jessie-backports main" | tee -a /etc/apt/sources.list.d/jessie-backports.list
11
12
13
14echo "===> Adding prerequisites..."
15
16apt-get update -y
17cat ___APT_INSTALL_LIST | \
18 while read ITEM; do
19 apt-get install -y $ITEM
20 done
21
22
23
24echo "===> Installing Ansible..."
25apt-get -t jessie-backports install -y ansible
26
27
28
29echo "===> Adding hosts for convenience..." && \
30mkdir -p /etc/ansible && \
31echo 'localhost' > /etc/ansible/hosts
diff --git a/mini-debian8/prepare-pkg-list.sh b/mini-debian8/prepare-pkg-list.sh
new file mode 100755
index 0000000..ce2195d
--- /dev/null
+++ b/mini-debian8/prepare-pkg-list.sh
@@ -0,0 +1,37 @@
1#!/bin/sh
2#
3# Prepare the list of packages to be installed/uninstalled.
4#
5# ENVIRONMENT VARIABLES:
6#
7# - APT_LIST: APT package list; default = "apt-list"
8#
9
10echo "===> Preparing APT package list..."
11
12if [ -z "$APT_LIST" ]; then
13 APT_LIST=apt-list
14fi
15
16if [ -f "$APT_LIST" ]; then
17
18 awk '/^#/ {next} \
19 { split($0,arrayA); \
20 for (i in arrayA) { \
21 if (arrayA[i] == "!") { continue; } \
22 print arrayA[i] \
23 } \
24 }' \
25 $APT_LIST > ___APT_INSTALL_LIST
26
27 awk '/^(#|!)/ {next} \
28 { split($0,arrayA); for (i in arrayA) print arrayA[i] }' \
29 $APT_LIST |
30 awk '{ L[n++] = $0 } \
31 END { while(n--) \
32 print L[n] }' \
33 > ___APT_UNINSTALL_LIST
34
35fi
36#cat ___APT_INSTALL_LIST
37#cat ___APT_UNINSTALL_LIST
diff --git a/mini-debian8/uninstall-ansible.sh b/mini-debian8/uninstall-ansible.sh
new file mode 100755
index 0000000..3573413
--- /dev/null
+++ b/mini-debian8/uninstall-ansible.sh
@@ -0,0 +1,21 @@
1#!/bin/sh
2#
3# Simple wrapper for uninstall ansible and related stuff.
4#
5
6
7echo "===> Removing Ansible..."
8apt-get -f -y --auto-remove remove ansible
9
10echo "===> Removing APT packages..."
11cat ___APT_UNINSTALL_LIST | \
12 while read ITEM; do
13 apt-get -f -y --auto-remove remove $ITEM
14 done
15apt-get clean
16
17
18echo "===> Cleaning up package list..."
19rm -rf /etc/python /etc/python2.7
20rm -rf /etc/ansible /root/.ansible /root/.cache
21rm -rf /var/lib/apt/lists/* /etc/apt/sources.list.d /var/cache/* /var/log/*
diff --git a/mini-test/Dockerfile.alpine3 b/mini-test/Dockerfile.alpine3
index 78e7521..a42fa33 100644
--- a/mini-test/Dockerfile.alpine3
+++ b/mini-test/Dockerfile.alpine3
@@ -3,7 +3,7 @@
3 3
4 4
5# pull base image 5# pull base image
6FROM ansible_mini_apline3 6FROM ansible_mini_alpine3
7 7
8MAINTAINER William Yeh <william.pjyeh@gmail.com> 8MAINTAINER William Yeh <william.pjyeh@gmail.com>
9 9
diff --git a/mini-test/Dockerfile.debian8 b/mini-test/Dockerfile.debian8
new file mode 100644
index 0000000..f41cbbb
--- /dev/null
+++ b/mini-test/Dockerfile.debian8
@@ -0,0 +1,14 @@
1# Dockerfile for building (near-)minimal nginx under Debian8
2#
3
4
5# pull base image
6FROM ansible_mini_debian8
7
8MAINTAINER William Yeh <william.pjyeh@gmail.com>
9
10#ENV APK_LIST apk-list
11
12ENTRYPOINT ["/usr/sbin/nginx"]
13#CMD ["-g", "daemon off;"]
14CMD ["-v"]
diff --git a/mini-test/playbook.yml b/mini-test/playbook.yml
index 898dfc5..b8cccda 100644
--- a/mini-test/playbook.yml
+++ b/mini-test/playbook.yml
@@ -1,5 +1,18 @@
1- hosts: all 1- hosts: all
2 become: True 2 become: true
3 tasks: 3 tasks:
4 - name: install nginx 4 - name: DEBUG
5 apk: name=nginx state=present 5 command: echo hello
6
7 - name: install nginx for Alpine
8 apk: name=nginx state=present
9 when: ansible_distribution == "Alpine"
10
11 - name: install nginx for Debian/Ubuntu
12 apt: name=nginx state=present
13 when: ansible_os_family == "Debian"
14
15
16# Debian:
17#rm -rf /etc/fonts /usr/share/fonts /usr/local/share/fonts /usr/share/X11 /usr/share/fontconfig /usr/share/doc
18#rm -rf /etc/perl /usr/lib/x86_64-linux-gnu/perl