- docker build -t ansible_master_centos7_onbuild master-centos7-onbuild
- docker build -t ansible_master_centos6_onbuild master-centos6-onbuild
+
+ - docker build -t ansible_mini_apline3 mini-alpine3
+ - docker build -t nginx_apline3 -f mini-test/Dockerfile.alpine3 mini-test
+
+
script:
- docker run -i ansible_xenial > result-ubuntu16.04
- docker run -i ansible_trusty > result-ubuntu14.04
- docker run -i ansible_master_centos6_onbuild > result-master-centos6-onbuild
+ - docker run -i nginx_apline3 2> result-nginx-alpine3
+
- echo "==> Validating the test results..."
- sh -c "[ -s result-ubuntu16.04 ]"
- sh -c "[ -s result-master-debian7-onbuild ]"
- sh -c "[ -s result-master-centos7-onbuild ]"
- sh -c "[ -s result-master-centos6-onbuild ]"
+
+ - sh -c "[ -s result-nginx-alpine3 ]"
- OS: Debian (jessie, wheezy), Ubuntu (xenial, trusty, precise), CentOS (7, 6), Alpine (3).
-- Ansible: three version series -
+- Ansible: four series -
1. the most recent *stable* version;
2. old 1.9 version;
- 3. the *experimental* version.
+ 3. the *experimental* version;
+ 4. for building *minimal* images from playbooks; i.e., the Ansible body will be removed when mission completed.
## Images and tags
- `williamyeh/ansible:master-centos6-onbuild`
+### Minimal series (the Ansible body will be removed when mission completed):
+
+- Onbuild series:
+
+ - `williamyeh/ansible:mini-alpine3`
+
+
## For the impatient
- docker build -t ansible_master_centos7_onbuild master-centos7-onbuild
- docker build -t ansible_master_centos6_onbuild master-centos6-onbuild
+
+ - docker build -t ansible_mini_apline3 mini-alpine3
+ - docker build -t nginx_apline3 -f mini-test/Dockerfile.alpine3 mini-test
+
+
test:
override:
- docker run -i ansible_xenial > result-ubuntu16.04
- docker run -i ansible_master_centos6_onbuild > result-master-centos6-onbuild
+ - docker run -i nginx_apline3 2> result-nginx-alpine3
+
- echo "==> Validating the test results..."
- sh -c "[ -s result-ubuntu16.04 ]"
- sh -c "[ -s result-master-debian7-onbuild ]"
- sh -c "[ -s result-master-centos7-onbuild ]"
- sh -c "[ -s result-master-centos6-onbuild ]"
+
+ - sh -c "[ -s result-nginx-alpine3 ]"
--- /dev/null
+# Dockerfile for building Alpine-based image, via Ansible playbooks.
+#
+# @see https://github.com/gliderlabs/docker-alpine/blob/master/docs/usage.md
+#
+# Version 1.0
+#
+
+
+# pull base image
+FROM alpine:3.3
+
+MAINTAINER William Yeh <william.pjyeh@gmail.com>
+
+#ENV APK_LIST apk-list
+#ENV PIP_LIST pip-list
+
+
+COPY . /tmp
+
+ONBUILD COPY . /tmp
+ONBUILD RUN \
+ cd /tmp && \
+ ./prepare-pkg-list.sh && \
+ ./install-ansible.sh && \
+ ./ansible-playbook-wrapper && \
+ ./uninstall-ansible.sh && \
+ cd / && \
+ rm -rf /tmp/*
--- /dev/null
+#!/bin/sh
+#
+# Simple wrapper for executing ansible-galaxy and ansible-playbook
+# with local connection.
+#
+# USAGE:
+# ansible-playbook-wrapper [other ansible-playbook arguments]
+#
+# ENVIRONMENT VARIABLES:
+#
+# - REQUIREMENTS: requirements filename; default = "requirements.yml"
+# - PLAYBOOK: playbook filename; default = "playbook.yml"
+# - INVENTORY: inventory filename; default = "/etc/ansible/hosts"
+#
+
+
+#
+# install Galaxy roles, if any
+#
+
+if [ -z "$REQUIREMENTS" ]; then
+ REQUIREMENTS=requirements.yml
+fi
+
+if [ -f "$REQUIREMENTS" ]; then
+ ansible-galaxy install -r $REQUIREMENTS
+fi
+
+
+#
+# execute playbook
+#
+
+if [ -z "$PLAYBOOK" ]; then
+ PLAYBOOK=playbook.yml
+fi
+
+
+if [ -z "$INVENTORY" ]; then
+ exec ansible-playbook \
+ $PLAYBOOK \
+ --connection=local \
+ "$@"
+else
+ exec ansible-playbook \
+ -i $INVENTORY $PLAYBOOK \
+ --connection=local \
+ "$@"
+fi
--- /dev/null
+#
+# packages to be installed via APK;
+# lines beginning with "! " (an exclamation mark, followed by a space) will *not* be *uninstalled* afterwards.
+#
+
+
+# ssl
+openssl ca-certificates
+
+# python-runtime
+python py-pip
+
+# build-dependencies
+python-dev libffi-dev openssl-dev build-base
--- /dev/null
+#!/bin/sh
+#
+# Simple wrapper for installing ansible
+#
+
+
+echo "===> Adding prerequisites..."
+
+cat ___APK_INSTALL_LIST | \
+ while read ITEM; do
+ apk --update add $ITEM
+ done
+
+cat ___PIP_INSTALL_LIST | \
+ while read ITEM; do
+ pip install --upgrade $ITEM
+ done
+
+
+echo "===> Installing Ansible..."
+pip install ansible
+
+
+echo "===> Adding hosts for convenience..." && \
+mkdir -p /etc/ansible && \
+echo 'localhost' > /etc/ansible/hosts
--- /dev/null
+#
+# packages to be installed via PIP;
+# lines beginning with "! " (an exclamation mark, followed by a space) will *not* be *uninstalled* afterwards.
+#
+
+
+# pip itself
+pip
+
+# for ansible
+cffi
--- /dev/null
+#!/bin/sh
+#
+# Prepare the list of packages to be installed/uninstalled.
+#
+# ENVIRONMENT VARIABLES:
+#
+# - APK_LIST: APK package list; default = "apk-list"
+# - PIP_LIST: PIP package list; default = "pip-list"
+#
+
+echo "===> Preparing APK package list..."
+
+if [ -z "$APK_LIST" ]; then
+ APK_LIST=apk-list
+fi
+
+if [ -f "$APK_LIST" ]; then
+
+ awk '/^#/ {next} \
+ { split($0,arrayA); \
+ for (i in arrayA) { \
+ if (arrayA[i] == "!") { continue; } \
+ print arrayA[i] \
+ } \
+ }' \
+ $APK_LIST > ___APK_INSTALL_LIST
+
+ awk '/^(#|!)/ {next} \
+ { split($0,arrayA); for (i in arrayA) print arrayA[i] }' \
+ $APK_LIST |
+ awk '{ L[n++] = $0 } \
+ END { while(n--) \
+ print L[n] }' \
+ > ___APK_UNINSTALL_LIST
+
+fi
+#cat ___APK_INSTALL_LIST
+#cat ___APK_UNINSTALL_LIST
+
+
+echo "===> Preparing PIP package list..."
+
+if [ -z "$PIP_LIST" ]; then
+ PIP_LIST=pip-list
+fi
+
+if [ -f "$PIP_LIST" ]; then
+
+ awk '/^#/ {next} \
+ { split($0,arrayA); \
+ for (i in arrayA) { \
+ if (arrayA[i] == "!") { continue; } \
+ print arrayA[i] \
+ } \
+ }' \
+ $PIP_LIST > ___PIP_INSTALL_LIST
+
+ awk '/^(#|!)/ {next} \
+ { split($0,arrayA); for (i in arrayA) print arrayA[i] }' \
+ $PIP_LIST |
+ awk '{ L[n++] = $0 } \
+ END { while(n--) \
+ print L[n] }' \
+ > ___PIP_UNINSTALL_LIST
+
+fi
+#cat ___PIP_INSTALL_LIST
+#cat ___PIP_UNINSTALL_LIST
--- /dev/null
+#!/bin/sh
+#
+# Simple wrapper for uninstall ansible and related stuff.
+#
+
+
+echo "===> Removing Ansible..."
+pip uninstall -y ansible
+
+echo "===> Removing PIP packages..."
+cat ___PIP_UNINSTALL_LIST | \
+ while read ITEM; do
+ pip uninstall -y $ITEM
+ done
+
+echo "===> Removing APK packages..."
+cat ___APK_UNINSTALL_LIST | \
+ while read ITEM; do
+ apk del $ITEM
+ done
+
+
+echo "===> Cleaning up package list..."
+rm -rf /var/lib/python2.7 /usr/lib/python2.7
+rm -rf /etc/ansible /root/.ansible /root/.cache /root/.ash_history
+rm -rf /var/cache/apk
--- /dev/null
+# Dockerfile for building (near-)minimal nginx
+#
+
+
+# pull base image
+FROM ansible_mini_apline3
+
+MAINTAINER William Yeh <william.pjyeh@gmail.com>
+
+#ENV APK_LIST apk-list
+#ENV PIP_LIST pip-list
+
+ENTRYPOINT ["/usr/sbin/nginx"]
+#CMD ["-g", "daemon off;"]
+CMD ["-v"]
--- /dev/null
+- hosts: all
+ become: True
+ tasks:
+ - name: install nginx
+ apk: name=nginx state=present