- 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
+ - docker build -t ansible_mini_alpine3 mini-alpine3
+ - docker build -t ansible_mini_debian8 mini-debian8
+ - docker build -t nginx_alpine3 -f mini-test/Dockerfile.alpine3 mini-test
+ - docker build -t nginx_debian8 -f mini-test/Dockerfile.debian8 mini-test
script:
- docker run -i ansible_master_centos6_onbuild > result-master-centos6-onbuild
- - docker run -i nginx_apline3 2> result-nginx-alpine3
+ - docker run -i nginx_alpine3 2> result-nginx-alpine3
+ - docker run -i nginx_debian8 2> result-nginx-debian8
- echo "==> Validating the test results..."
- sh -c "[ -s result-master-centos6-onbuild ]"
- sh -c "[ -s result-nginx-alpine3 ]"
+ - sh -c "[ -s result-nginx-debian8 ]"
- Onbuild series:
- `williamyeh/ansible:mini-alpine3`
+ - `williamyeh/ansible:mini-debian8`
- 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
+ - docker build -t ansible_mini_alpine3 mini-alpine3
+ - docker build -t ansible_mini_debian8 mini-debian8
+ - docker build -t nginx_alpine3 -f mini-test/Dockerfile.alpine3 mini-test
+ - docker build -t nginx_debian8 -f mini-test/Dockerfile.debian8 mini-test
test:
- docker run -i ansible_master_centos6_onbuild > result-master-centos6-onbuild
- - docker run -i nginx_apline3 2> result-nginx-alpine3
+ - docker run -i nginx_alpine3 2> result-nginx-alpine3
+ - docker run -i nginx_debian8 2> result-nginx-debian8
- echo "==> Validating the test results..."
- sh -c "[ -s result-master-centos6-onbuild ]"
- sh -c "[ -s result-nginx-alpine3 ]"
+ - sh -c "[ -s result-nginx-debian8 ]"
--- /dev/null
+# Dockerfile for building Debian-based image, via Ansible playbooks.
+#
+# @see http://docs.ansible.com/ansible/intro_installation.html#running-from-source
+#
+# Version 1.0
+#
+
+
+# pull base image
+FROM debian:8
+
+MAINTAINER William Yeh <william.pjyeh@gmail.com>
+
+#ENV APT_LIST apt-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/*
\ No newline at end of file
--- /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 APT;
+# lines beginning with "! " (an exclamation mark, followed by a space) will *not* be *uninstalled* afterwards.
+#
+
+
+# common
+#####sudo curl gcc
+
+# ssl
+#####openssl ca-certificates
+
+# python-runtime
+python
+#####python-pip python-yaml
+
+# build-dependencies
+#####python-dev libffi-dev libssl-dev
\ No newline at end of file
--- /dev/null
+#!/bin/sh
+#
+# Simple wrapper for installing ansible
+#
+
+
+echo "===> Adding backports..."
+
+mkdir -p /etc/apt/sources.list.d/
+echo "deb http://ftp.debian.org/debian jessie-backports main" | tee -a /etc/apt/sources.list.d/jessie-backports.list
+
+
+
+echo "===> Adding prerequisites..."
+
+apt-get update -y
+cat ___APT_INSTALL_LIST | \
+ while read ITEM; do
+ apt-get install -y $ITEM
+ done
+
+
+
+echo "===> Installing Ansible..."
+apt-get -t jessie-backports install -y ansible
+
+
+
+echo "===> Adding hosts for convenience..." && \
+mkdir -p /etc/ansible && \
+echo 'localhost' > /etc/ansible/hosts
--- /dev/null
+#!/bin/sh
+#
+# Prepare the list of packages to be installed/uninstalled.
+#
+# ENVIRONMENT VARIABLES:
+#
+# - APT_LIST: APT package list; default = "apt-list"
+#
+
+echo "===> Preparing APT package list..."
+
+if [ -z "$APT_LIST" ]; then
+ APT_LIST=apt-list
+fi
+
+if [ -f "$APT_LIST" ]; then
+
+ awk '/^#/ {next} \
+ { split($0,arrayA); \
+ for (i in arrayA) { \
+ if (arrayA[i] == "!") { continue; } \
+ print arrayA[i] \
+ } \
+ }' \
+ $APT_LIST > ___APT_INSTALL_LIST
+
+ awk '/^(#|!)/ {next} \
+ { split($0,arrayA); for (i in arrayA) print arrayA[i] }' \
+ $APT_LIST |
+ awk '{ L[n++] = $0 } \
+ END { while(n--) \
+ print L[n] }' \
+ > ___APT_UNINSTALL_LIST
+
+fi
+#cat ___APT_INSTALL_LIST
+#cat ___APT_UNINSTALL_LIST
--- /dev/null
+#!/bin/sh
+#
+# Simple wrapper for uninstall ansible and related stuff.
+#
+
+
+echo "===> Removing Ansible..."
+apt-get -f -y --auto-remove remove ansible
+
+echo "===> Removing APT packages..."
+cat ___APT_UNINSTALL_LIST | \
+ while read ITEM; do
+ apt-get -f -y --auto-remove remove $ITEM
+ done
+apt-get clean
+
+
+echo "===> Cleaning up package list..."
+rm -rf /etc/python /etc/python2.7
+rm -rf /etc/ansible /root/.ansible /root/.cache
+rm -rf /var/lib/apt/lists/* /etc/apt/sources.list.d /var/cache/* /var/log/*
# pull base image
-FROM ansible_mini_apline3
+FROM ansible_mini_alpine3
MAINTAINER William Yeh <william.pjyeh@gmail.com>
--- /dev/null
+# Dockerfile for building (near-)minimal nginx under Debian8
+#
+
+
+# pull base image
+FROM ansible_mini_debian8
+
+MAINTAINER William Yeh <william.pjyeh@gmail.com>
+
+#ENV APK_LIST apk-list
+
+ENTRYPOINT ["/usr/sbin/nginx"]
+#CMD ["-g", "daemon off;"]
+CMD ["-v"]
- hosts: all
- become: True
+ become: true
tasks:
- - name: install nginx
- apk: name=nginx state=present
+ - name: DEBUG
+ command: echo hello
+
+ - name: install nginx for Alpine
+ apk: name=nginx state=present
+ when: ansible_distribution == "Alpine"
+
+ - name: install nginx for Debian/Ubuntu
+ apt: name=nginx state=present
+ when: ansible_os_family == "Debian"
+
+
+# Debian:
+#rm -rf /etc/fonts /usr/share/fonts /usr/local/share/fonts /usr/share/X11 /usr/share/fontconfig /usr/share/doc
+#rm -rf /etc/perl /usr/lib/x86_64-linux-gnu/perl