diff options
-rw-r--r-- | .travis.yml | 10 | ||||
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | circle.yml | 10 | ||||
-rw-r--r-- | mini-debian8/Dockerfile | 27 | ||||
-rwxr-xr-x | mini-debian8/ansible-playbook-wrapper | 49 | ||||
-rw-r--r-- | mini-debian8/apt-list | 18 | ||||
-rwxr-xr-x | mini-debian8/install-ansible.sh | 31 | ||||
-rwxr-xr-x | mini-debian8/prepare-pkg-list.sh | 37 | ||||
-rwxr-xr-x | mini-debian8/uninstall-ansible.sh | 21 | ||||
-rw-r--r-- | mini-test/Dockerfile.alpine3 | 2 | ||||
-rw-r--r-- | mini-test/Dockerfile.debian8 | 14 | ||||
-rw-r--r-- | mini-test/playbook.yml | 19 |
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 | ||
66 | script: | 68 | script: |
@@ -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 ]" | ||
@@ -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 | ||
@@ -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 | ||
67 | test: | 69 | test: |
@@ -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 | ||
10 | FROM debian:8 | ||
11 | |||
12 | MAINTAINER William Yeh <william.pjyeh@gmail.com> | ||
13 | |||
14 | #ENV APT_LIST apt-list | ||
15 | |||
16 | |||
17 | COPY . /tmp | ||
18 | |||
19 | ONBUILD COPY . /tmp | ||
20 | ONBUILD 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 | |||
21 | if [ -z "$REQUIREMENTS" ]; then | ||
22 | REQUIREMENTS=requirements.yml | ||
23 | fi | ||
24 | |||
25 | if [ -f "$REQUIREMENTS" ]; then | ||
26 | ansible-galaxy install -r $REQUIREMENTS | ||
27 | fi | ||
28 | |||
29 | |||
30 | # | ||
31 | # execute playbook | ||
32 | # | ||
33 | |||
34 | if [ -z "$PLAYBOOK" ]; then | ||
35 | PLAYBOOK=playbook.yml | ||
36 | fi | ||
37 | |||
38 | |||
39 | if [ -z "$INVENTORY" ]; then | ||
40 | exec ansible-playbook \ | ||
41 | $PLAYBOOK \ | ||
42 | --connection=local \ | ||
43 | "$@" | ||
44 | else | ||
45 | exec ansible-playbook \ | ||
46 | -i $INVENTORY $PLAYBOOK \ | ||
47 | --connection=local \ | ||
48 | "$@" | ||
49 | fi | ||
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 | ||
14 | python | ||
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 | |||
7 | echo "===> Adding backports..." | ||
8 | |||
9 | mkdir -p /etc/apt/sources.list.d/ | ||
10 | echo "deb http://ftp.debian.org/debian jessie-backports main" | tee -a /etc/apt/sources.list.d/jessie-backports.list | ||
11 | |||
12 | |||
13 | |||
14 | echo "===> Adding prerequisites..." | ||
15 | |||
16 | apt-get update -y | ||
17 | cat ___APT_INSTALL_LIST | \ | ||
18 | while read ITEM; do | ||
19 | apt-get install -y $ITEM | ||
20 | done | ||
21 | |||
22 | |||
23 | |||
24 | echo "===> Installing Ansible..." | ||
25 | apt-get -t jessie-backports install -y ansible | ||
26 | |||
27 | |||
28 | |||
29 | echo "===> Adding hosts for convenience..." && \ | ||
30 | mkdir -p /etc/ansible && \ | ||
31 | echo '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 | |||
10 | echo "===> Preparing APT package list..." | ||
11 | |||
12 | if [ -z "$APT_LIST" ]; then | ||
13 | APT_LIST=apt-list | ||
14 | fi | ||
15 | |||
16 | if [ -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 | |||
35 | fi | ||
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 | |||
7 | echo "===> Removing Ansible..." | ||
8 | apt-get -f -y --auto-remove remove ansible | ||
9 | |||
10 | echo "===> Removing APT packages..." | ||
11 | cat ___APT_UNINSTALL_LIST | \ | ||
12 | while read ITEM; do | ||
13 | apt-get -f -y --auto-remove remove $ITEM | ||
14 | done | ||
15 | apt-get clean | ||
16 | |||
17 | |||
18 | echo "===> Cleaning up package list..." | ||
19 | rm -rf /etc/python /etc/python2.7 | ||
20 | rm -rf /etc/ansible /root/.ansible /root/.cache | ||
21 | rm -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 |
6 | FROM ansible_mini_apline3 | 6 | FROM ansible_mini_alpine3 |
7 | 7 | ||
8 | MAINTAINER William Yeh <william.pjyeh@gmail.com> | 8 | MAINTAINER 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 | ||
6 | FROM ansible_mini_debian8 | ||
7 | |||
8 | MAINTAINER William Yeh <william.pjyeh@gmail.com> | ||
9 | |||
10 | #ENV APK_LIST apk-list | ||
11 | |||
12 | ENTRYPOINT ["/usr/sbin/nginx"] | ||
13 | #CMD ["-g", "daemon off;"] | ||
14 | CMD ["-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 | ||