From deeab1a101da6710574174dbe47199f9e8900b93 Mon Sep 17 00:00:00 2001 From: William Yeh Date: Thu, 14 Sep 2017 15:57:43 +0800 Subject: Add: Debian 9 ("Stretch") support. --- .travis.yml | 16 +++++ README.md | 22 ++++--- Vagrantfile | 2 + circle.yml | 16 +++++ debian9-onbuild/Dockerfile | 56 ++++++++++++++++++ debian9-onbuild/ansible-playbook-wrapper | 50 ++++++++++++++++ debian9/Dockerfile | 48 +++++++++++++++ master-debian9-onbuild/Dockerfile | 78 +++++++++++++++++++++++++ master-debian9-onbuild/ansible-playbook-wrapper | 50 ++++++++++++++++ master-debian9/Dockerfile | 69 ++++++++++++++++++++++ mini-debian8/install-ansible.sh | 3 + mini-debian9/Dockerfile | 27 +++++++++ mini-debian9/ansible-playbook-wrapper | 49 ++++++++++++++++ mini-debian9/apt-list | 21 +++++++ mini-debian9/install-ansible.sh | 27 +++++++++ mini-debian9/prepare-pkg-list.sh | 37 ++++++++++++ mini-debian9/uninstall-ansible.sh | 21 +++++++ mini-test/Dockerfile.debian9 | 14 +++++ 18 files changed, 599 insertions(+), 7 deletions(-) create mode 100644 debian9-onbuild/Dockerfile create mode 100755 debian9-onbuild/ansible-playbook-wrapper create mode 100644 debian9/Dockerfile create mode 100644 master-debian9-onbuild/Dockerfile create mode 100755 master-debian9-onbuild/ansible-playbook-wrapper create mode 100644 master-debian9/Dockerfile create mode 100644 mini-debian9/Dockerfile create mode 100755 mini-debian9/ansible-playbook-wrapper create mode 100644 mini-debian9/apt-list create mode 100755 mini-debian9/install-ansible.sh create mode 100755 mini-debian9/prepare-pkg-list.sh create mode 100755 mini-debian9/uninstall-ansible.sh create mode 100644 mini-test/Dockerfile.debian9 diff --git a/.travis.yml b/.travis.yml index 7d2af6d..0e29db1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,12 +8,14 @@ before_install: - docker build -t ansible_xenial ubuntu16.04 - docker build -t ansible_trusty ubuntu14.04 + - docker build -t ansible_stretch debian9 - docker build -t ansible_jessie debian8 - docker build -t ansible_centos7 centos7 - docker build -t ansible_alpine3 alpine3 - docker build -t ansible_xenial_onbuild ubuntu16.04-onbuild - docker build -t ansible_trusty_onbuild ubuntu14.04-onbuild + - docker build -t ansible_stretch_onbuild debian9-onbuild - docker build -t ansible_jessie_onbuild debian8-onbuild - docker build -t ansible_centos7_onbuild centos7-onbuild - docker build -t ansible_alpine3_onbuild alpine3-onbuild @@ -30,29 +32,35 @@ before_install: - docker build -t ansible_master_xenial master-ubuntu16.04 - docker build -t ansible_master_trusty master-ubuntu14.04 + - docker build -t ansible_master_stretch master-debian9 - docker build -t ansible_master_jessie master-debian8 - docker build -t ansible_master_centos7 master-centos7 - docker build -t ansible_master_xenial_onbuild master-ubuntu16.04-onbuild - docker build -t ansible_master_trusty_onbuild master-ubuntu14.04-onbuild + - docker build -t ansible_master_stretch_onbuild master-debian9-onbuild - docker build -t ansible_master_jessie_onbuild master-debian8-onbuild - docker build -t ansible_master_centos7_onbuild master-centos7-onbuild - docker build -t ansible_mini_alpine3 mini-alpine3 + - docker build -t ansible_mini_debian9 mini-debian9 - docker build -t ansible_mini_debian8 mini-debian8 - docker build -t nginx_alpine3 -f mini-test/Dockerfile.alpine3 mini-test + - docker build -t nginx_debian9 -f mini-test/Dockerfile.debian9 mini-test - docker build -t nginx_debian8 -f mini-test/Dockerfile.debian8 mini-test script: - docker run -i ansible_xenial > result-ubuntu16.04 - docker run -i ansible_trusty > result-ubuntu14.04 + - docker run -i ansible_stretch > result-debian9 - docker run -i ansible_jessie > result-debian8 - docker run -i ansible_centos7 > result-centos7 - docker run -i ansible_alpine3 > result-alpine3 - docker run -i ansible_xenial_onbuild > result-ubuntu16.04-onbuild - docker run -i ansible_trusty_onbuild > result-ubuntu14.04-onbuild + - docker run -i ansible_stretch_onbuild > result-debian9-onbuild - docker run -i ansible_jessie_onbuild > result-debian8-onbuild - docker run -i ansible_centos7_onbuild > result-centos7-onbuild - docker run -i ansible_alpine3_onbuild > result-alpine3-onbuild @@ -68,26 +76,31 @@ script: - docker run -i ansible_master_xenial > result-master-ubuntu16.04 - docker run -i ansible_master_trusty > result-master-ubuntu14.04 + - docker run -i ansible_master_stretch > result-master-debian9 - docker run -i ansible_master_jessie > result-master-debian8 - docker run -i ansible_master_centos7 > result-master-centos7 - docker run -i ansible_master_xenial_onbuild > result-master-ubuntu16.04-onbuild - docker run -i ansible_master_trusty_onbuild > result-master-ubuntu14.04-onbuild + - docker run -i ansible_master_stretch_onbuild > result-master-debian9-onbuild - docker run -i ansible_master_jessie_onbuild > result-master-debian8-onbuild - docker run -i ansible_master_centos7_onbuild > result-master-centos7-onbuild - docker run -i nginx_alpine3 2> result-nginx-alpine3 + - docker run -i nginx_debian9 2> result-nginx-debian9 - docker run -i nginx_debian8 2> result-nginx-debian8 - echo "==> Validating the test results..." - sh -c "[ -s result-ubuntu16.04 ]" - sh -c "[ -s result-ubuntu14.04 ]" + - sh -c "[ -s result-debian9 ]" - sh -c "[ -s result-debian8 ]" - sh -c "[ -s result-centos7 ]" - sh -c "[ -s result-alpine3 ]" - sh -c "[ -s result-ubuntu16.04-onbuild ]" - sh -c "[ -s result-ubuntu14.04-onbuild ]" + - sh -c "[ -s result-debian9-onbuild ]" - sh -c "[ -s result-debian8-onbuild ]" - sh -c "[ -s result-centos7-onbuild ]" - sh -c "[ -s result-alpine3-onbuild ]" @@ -101,12 +114,15 @@ script: - sh -c "[ -s result-master-ubuntu16.04 ]" - sh -c "[ -s result-master-ubuntu14.04 ]" + - sh -c "[ -s result-master-debian9 ]" - sh -c "[ -s result-master-debian8 ]" - sh -c "[ -s result-master-centos7 ]" - sh -c "[ -s result-master-ubuntu16.04-onbuild ]" - sh -c "[ -s result-master-ubuntu14.04-onbuild ]" + - sh -c "[ -s result-master-debian9-onbuild ]" - sh -c "[ -s result-master-debian8-onbuild ]" - sh -c "[ -s result-master-centos7-onbuild ]" - sh -c "[ -s result-nginx-alpine3 ]" + - sh -c "[ -s result-nginx-debian9 ]" - sh -c "[ -s result-nginx-debian8 ]" diff --git a/README.md b/README.md index c02360d..58627ac 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ These are Docker images for [Ansible](https://github.com/ansible/ansible) softwa ### Base OS -Debian (jessie), Ubuntu (xenial, trusty), CentOS (7), Alpine (3). +Debian (stretch, jessie), Ubuntu (xenial, trusty), CentOS (7), Alpine (3). Supports for Wheezy, Precise, and CentOS6 have been ended since Sep 2017. @@ -43,6 +43,7 @@ Each version is further divided into two variants: - Normal variants: + - `williamyeh/ansible:debian9` - `williamyeh/ansible:debian8` - `williamyeh/ansible:ubuntu16.04` - `williamyeh/ansible:ubuntu14.04` @@ -51,6 +52,7 @@ Each version is further divided into two variants: - Onbuild variants (*recommended for common cases*): + - `williamyeh/ansible:debian9-onbuild` - `williamyeh/ansible:debian8-onbuild` - `williamyeh/ansible:ubuntu16.04-onbuild` - `williamyeh/ansible:ubuntu14.04-onbuild` @@ -65,6 +67,7 @@ Refer to “[Build Docker images with Ansible: A half-blood approach](https://gi - Onbuild variants: - `williamyeh/ansible:mini-alpine3` + - `williamyeh/ansible:mini-debian9` - `williamyeh/ansible:mini-debian8` @@ -89,6 +92,7 @@ Note: Ansible 1.9 was not supported in CentOS EPEL since January 2017, according - Normal variants: + - `williamyeh/ansible:master-debian9` - `williamyeh/ansible:master-debian8` - `williamyeh/ansible:master-ubuntu16.04` - `williamyeh/ansible:master-ubuntu14.04` @@ -96,6 +100,7 @@ Note: Ansible 1.9 was not supported in CentOS EPEL since January 2017, according - Onbuild variants (*recommended for common cases*): + - `williamyeh/ansible:master-debian9-onbuild` - `williamyeh/ansible:master-debian8-onbuild` - `williamyeh/ansible:master-ubuntu16.04-onbuild` - `williamyeh/ansible:master-ubuntu14.04-onbuild` @@ -180,8 +185,9 @@ Take Debian/Ubuntu/CentOS for example. To test an Ansible `playbook.yml` against Vagrant.configure(2) do |config| # ==> Choose a Vagrant box to emulate Linux distribution... - #config.vm.box = "ubuntu/xenial64" - config.vm.box = "ubuntu/trusty64" + config.vm.box = "ubuntu/xenial64" + #config.vm.box = "ubuntu/trusty64" + #config.vm.box = "debian/stretch64" #config.vm.box = "debian/jessie64" #config.vm.box = "bento/centos-7.2" #config.vm.box = "maier/alpine-3.3.1-x86_64" @@ -205,8 +211,9 @@ Docker to be a rescue. Now, with these **williamyeh/ansible** series, we may tes # Dockerfile # ==> Choose a base image to emulate Linux distribution... -#FROM williamyeh/ansible:ubuntu16.04 -FROM williamyeh/ansible:ubuntu14.04 +FROM williamyeh/ansible:ubuntu16.04 +#FROM williamyeh/ansible:ubuntu14.04 +#FROM williamyeh/ansible:debian9 #FROM williamyeh/ansible:debian8 #FROM williamyeh/ansible:centos7 #FROM williamyeh/ansible:alpine3 @@ -230,8 +237,9 @@ You may also work with `onbuild` variants, which take care of many routine steps # Dockerfile # ==> Choose a base image to emulate Linux distribution... -#FROM williamyeh/ansible:ubuntu16.04-onbuild -FROM williamyeh/ansible:ubuntu14.04-onbuild +FROM williamyeh/ansible:ubuntu16.04-onbuild +#FROM williamyeh/ansible:ubuntu14.04-onbuild +#FROM williamyeh/ansible:debian9-onbuild #FROM williamyeh/ansible:debian8-onbuild #FROM williamyeh/ansible:centos7-onbuild #FROM williamyeh/ansible:alpine3-onbuild diff --git a/Vagrantfile b/Vagrantfile index 2e1a5e9..14e558e 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -6,12 +6,14 @@ Vagrant.configure(2) do |config| docker build -t ansible:ubuntu16.04 ubuntu16.04 docker build -t ansible:ubuntu14.04 ubuntu14.04 + docker build -t ansible:debian9 debian9 docker build -t ansible:debian8 debian8 docker build -t ansible:centos7 centos7 docker build -t ansible:alpine3 alpine3 docker build -t ansible:ubuntu16.04-onbuild ubuntu16.04-onbuild docker build -t ansible:ubuntu14.04-onbuild ubuntu14.04-onbuild + docker build -t ansible:debian9-onbuild debian9-onbuild docker build -t ansible:debian8-onbuild debian8-onbuild docker build -t ansible:centos7-onbuild centos7-onbuild docker build -t ansible:alpine3-onbuild alpine3-onbuild diff --git a/circle.yml b/circle.yml index 61efc17..b0db43f 100644 --- a/circle.yml +++ b/circle.yml @@ -9,12 +9,14 @@ dependencies: - docker build -t ansible_xenial ubuntu16.04 - docker build -t ansible_trusty ubuntu14.04 + - docker build -t ansible_stretch debian9 - docker build -t ansible_jessie debian8 - docker build -t ansible_centos7 centos7 - docker build -t ansible_alpine3 alpine3 - docker build -t ansible_xenial_onbuild ubuntu16.04-onbuild - docker build -t ansible_trusty_onbuild ubuntu14.04-onbuild + - docker build -t ansible_stretch_onbuild debian9-onbuild - docker build -t ansible_jessie_onbuild debian8-onbuild - docker build -t ansible_centos7_onbuild centos7-onbuild - docker build -t ansible_alpine3_onbuild alpine3-onbuild @@ -31,18 +33,22 @@ dependencies: - docker build -t ansible_master_xenial master-ubuntu16.04 - docker build -t ansible_master_trusty master-ubuntu14.04 + - docker build -t ansible_master_stretch master-debian9 - docker build -t ansible_master_jessie master-debian8 - docker build -t ansible_master_centos7 master-centos7 - docker build -t ansible_master_xenial_onbuild master-ubuntu16.04-onbuild - docker build -t ansible_master_trusty_onbuild master-ubuntu14.04-onbuild + - docker build -t ansible_master_stretch_onbuild master-debian9-onbuild - docker build -t ansible_master_jessie_onbuild master-debian8-onbuild - docker build -t ansible_master_centos7_onbuild master-centos7-onbuild - docker build -t ansible_mini_alpine3 mini-alpine3 + - docker build -t ansible_mini_debian9 mini-debian9 - docker build -t ansible_mini_debian8 mini-debian8 - docker build -t nginx_alpine3 -f mini-test/Dockerfile.alpine3 mini-test + - docker build -t nginx_debian9 -f mini-test/Dockerfile.debian9 mini-test - docker build -t nginx_debian8 -f mini-test/Dockerfile.debian8 mini-test @@ -50,11 +56,13 @@ test: override: - docker run -i ansible_xenial > result-ubuntu16.04 - docker run -i ansible_trusty > result-ubuntu14.04 + - docker run -i ansible_stretch > result-debian9 - docker run -i ansible_jessie > result-debian8 - docker run -i ansible_centos7 > result-centos7 - docker run -i ansible_alpine3 > result-alpine3 - docker run -i ansible_xenial_onbuild > result-ubuntu16.04-onbuild - docker run -i ansible_trusty_onbuild > result-ubuntu14.04-onbuild + - docker run -i ansible_stretch_onbuild > result-debian9-onbuild - docker run -i ansible_jessie_onbuild > result-debian8-onbuild - docker run -i ansible_centos7_onbuild > result-centos7-onbuild - docker run -i ansible_alpine3_onbuild > result-alpine3-onbuild @@ -70,26 +78,31 @@ test: - docker run -i ansible_master_xenial > result-master-ubuntu16.04 - docker run -i ansible_master_trusty > result-master-ubuntu14.04 + - docker run -i ansible_master_stretch > result-master-debian9 - docker run -i ansible_master_jessie > result-master-debian8 - docker run -i ansible_master_centos7 > result-master-centos7 - docker run -i ansible_master_xenial_onbuild > result-master-ubuntu16.04-onbuild - docker run -i ansible_master_trusty_onbuild > result-master-ubuntu14.04-onbuild + - docker run -i ansible_master_stretch_onbuild > result-master-debian9-onbuild - docker run -i ansible_master_jessie_onbuild > result-master-debian8-onbuild - docker run -i ansible_master_centos7_onbuild > result-master-centos7-onbuild - docker run -i nginx_alpine3 2> result-nginx-alpine3 + - docker run -i nginx_debian9 2> result-nginx-debian9 - docker run -i nginx_debian8 2> result-nginx-debian8 - echo "==> Validating the test results..." - sh -c "[ -s result-ubuntu16.04 ]" - sh -c "[ -s result-ubuntu14.04 ]" + - sh -c "[ -s result-debian9 ]" - sh -c "[ -s result-debian8 ]" - sh -c "[ -s result-centos7 ]" - sh -c "[ -s result-alpine3 ]" - sh -c "[ -s result-ubuntu16.04-onbuild ]" - sh -c "[ -s result-ubuntu14.04-onbuild ]" + - sh -c "[ -s result-debian9-onbuild ]" - sh -c "[ -s result-debian8-onbuild ]" - sh -c "[ -s result-centos7-onbuild ]" - sh -c "[ -s result-alpine3-onbuild ]" @@ -103,12 +116,15 @@ test: - sh -c "[ -s result-master-ubuntu16.04 ]" - sh -c "[ -s result-master-ubuntu14.04 ]" + - sh -c "[ -s result-master-debian9 ]" - sh -c "[ -s result-master-debian8 ]" - sh -c "[ -s result-master-centos7 ]" - sh -c "[ -s result-master-ubuntu16.04-onbuild ]" - sh -c "[ -s result-master-ubuntu14.04-onbuild ]" + - sh -c "[ -s result-master-debian9-onbuild ]" - sh -c "[ -s result-master-debian8-onbuild ]" - sh -c "[ -s result-master-centos7-onbuild ]" - sh -c "[ -s result-nginx-alpine3 ]" + - sh -c "[ -s result-nginx-debian9 ]" - sh -c "[ -s result-nginx-debian8 ]" diff --git a/debian9-onbuild/Dockerfile b/debian9-onbuild/Dockerfile new file mode 100644 index 0000000..079ebd9 --- /dev/null +++ b/debian9-onbuild/Dockerfile @@ -0,0 +1,56 @@ +# Dockerfile for building Ansible image for Debian 9 (stretch), with as few additional software as possible. +# +# @see https://launchpad.net/~ansible/+archive/ubuntu/ansible +# +# Version 1.0 +# + + +# pull base image +FROM debian:stretch + +MAINTAINER William Yeh + + +RUN echo "===> Installing python, sudo, and supporting tools..." && \ + apt-get update -y && apt-get install --fix-missing && \ + DEBIAN_FRONTEND=noninteractive \ + apt-get install -y \ + python python-yaml sudo \ + curl gcc python-pip python-dev libffi-dev libssl-dev && \ + apt-get -y --purge remove python-cffi && \ + pip install --upgrade cffi && \ + \ + \ + echo "===> Installing Ansible..." && \ + pip install ansible && \ + \ + \ + echo "===> Removing unused APT resources..." && \ + apt-get -f -y --auto-remove remove \ + gcc python-pip python-dev libffi-dev libssl-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* /tmp/* && \ + \ + \ + echo "===> Adding hosts for convenience..." && \ + mkdir -p /etc/ansible && \ + echo 'localhost' > /etc/ansible/hosts + + +COPY ansible-playbook-wrapper /usr/local/bin/ + +ONBUILD RUN DEBIAN_FRONTEND=noninteractive apt-get update && \ + echo "===> Updating TLS certificates..." && \ + apt-get install -y openssl ca-certificates + +ONBUILD WORKDIR /tmp +ONBUILD COPY . /tmp +ONBUILD RUN \ + echo "===> Diagnosis: host information..." && \ + ansible -c local -m setup all + + + +# default command: display Ansible version +CMD [ "ansible-playbook", "--version" ] diff --git a/debian9-onbuild/ansible-playbook-wrapper b/debian9-onbuild/ansible-playbook-wrapper new file mode 100755 index 0000000..afe4d97 --- /dev/null +++ b/debian9-onbuild/ansible-playbook-wrapper @@ -0,0 +1,50 @@ +#!/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 + apt-get install -y git + 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 diff --git a/debian9/Dockerfile b/debian9/Dockerfile new file mode 100644 index 0000000..c6e16a5 --- /dev/null +++ b/debian9/Dockerfile @@ -0,0 +1,48 @@ +# Dockerfile for building Ansible image for Debian 9 (stretch), with as few additional software as possible. +# +# @see https://launchpad.net/~ansible/+archive/ubuntu/ansible +# +# Version 1.0 +# + + +# pull base image +FROM debian:stretch + +MAINTAINER William Yeh + + +RUN echo "===> Installing python, sudo, and supporting tools..." && \ + apt-get update -y && apt-get install --fix-missing && \ + DEBIAN_FRONTEND=noninteractive \ + apt-get install -y \ + python python-yaml sudo \ + curl gcc python-pip python-dev libffi-dev libssl-dev && \ + apt-get -y --purge remove python-cffi && \ + pip install --upgrade cffi pywinrm && \ + \ + \ + \ + echo "===> Installing Ansible..." && \ + pip install ansible && \ + \ + \ + \ + echo "===> Installing handy tools (not absolutely required)..." && \ + apt-get install -y sshpass openssh-client && \ + \ + \ + echo "===> Removing unused APT resources..." && \ + apt-get -f -y --auto-remove remove \ + gcc python-pip python-dev libffi-dev libssl-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* /tmp/* && \ + \ + \ + echo "===> Adding hosts for convenience..." && \ + mkdir -p /etc/ansible && \ + echo 'localhost' > /etc/ansible/hosts + + +# default command: display Ansible version +CMD [ "ansible-playbook", "--version" ] diff --git a/master-debian9-onbuild/Dockerfile b/master-debian9-onbuild/Dockerfile new file mode 100644 index 0000000..dafbdf3 --- /dev/null +++ b/master-debian9-onbuild/Dockerfile @@ -0,0 +1,78 @@ +# Dockerfile for building Ansible image from source for Debian 9 (stretch), with as few additional software as possible. +# +# @see http://docs.ansible.com/ansible/intro_installation.html#running-from-source +# +# Version 1.0 +# + + +# pull base image +FROM debian:stretch + +MAINTAINER William Yeh + + +RUN echo "===> Adding Ansible's prerequisites..." && \ + apt-get update -y && apt-get install --fix-missing && \ + DEBIAN_FRONTEND=noninteractive \ + apt-get install --no-install-recommends -y -q \ + build-essential ca-certificates \ + python python-pip python-dev \ + libffi-dev libssl-dev \ + libxml2-dev libxslt1-dev zlib1g-dev \ + git sudo curl && \ + pip install --upgrade setuptools pip wheel && \ + pip install --upgrade cffi && \ + pip install --upgrade pyyaml jinja2 pycrypto && \ + \ + \ + echo "===> Downloading Ansible's source tree..." && \ + git clone git://github.com/ansible/ansible.git --recursive && \ + \ + \ + echo "===> Compiling Ansible..." && \ + cd ansible && \ + bash -c 'source ./hacking/env-setup' && \ + \ + \ + echo "===> Moving useful Ansible stuff to /opt/ansible ..." && \ + mkdir -p /opt/ansible && \ + mv /ansible/bin /opt/ansible/bin && \ + mv /ansible/lib /opt/ansible/lib && \ + mv /ansible/docs /opt/ansible/docs && \ + rm -rf /ansible && \ + \ + \ + echo "===> Clean up..." && \ + apt-get remove -y --auto-remove \ + build-essential python-pip python-dev git libffi-dev libssl-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* && \ + \ + \ + echo "===> Adding hosts for convenience..." && \ + mkdir -p /etc/ansible && \ + echo 'localhost' > /etc/ansible/hosts + + +ENV PATH /opt/ansible/bin:$PATH +ENV PYTHONPATH /opt/ansible/lib:$PYTHONPATH +ENV MANPATH /opt/ansible/docs/man:$MANPATH + + +COPY ansible-playbook-wrapper /usr/local/bin/ + +ONBUILD RUN DEBIAN_FRONTEND=noninteractive apt-get update && \ + echo "===> Updating TLS certificates..." && \ + apt-get install -y openssl ca-certificates + +ONBUILD WORKDIR /tmp +ONBUILD COPY . /tmp +ONBUILD RUN \ + echo "===> Diagnosis: host information..." && \ + ansible -c local -m setup all + + + +# default command: display Ansible version +CMD [ "ansible-playbook", "--version" ] diff --git a/master-debian9-onbuild/ansible-playbook-wrapper b/master-debian9-onbuild/ansible-playbook-wrapper new file mode 100755 index 0000000..afe4d97 --- /dev/null +++ b/master-debian9-onbuild/ansible-playbook-wrapper @@ -0,0 +1,50 @@ +#!/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 + apt-get install -y git + 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 diff --git a/master-debian9/Dockerfile b/master-debian9/Dockerfile new file mode 100644 index 0000000..ef4c14f --- /dev/null +++ b/master-debian9/Dockerfile @@ -0,0 +1,69 @@ +# Dockerfile for building Ansible image from source for Debian 9 (stretch), with as few additional software as possible. +# +# @see http://docs.ansible.com/ansible/intro_installation.html#running-from-source +# +# Version 1.0 +# + + +# pull base image +FROM debian:stretch + +MAINTAINER William Yeh + + +RUN echo "===> Adding Ansible's prerequisites..." && \ + apt-get update -y && apt-get install --fix-missing && \ + DEBIAN_FRONTEND=noninteractive \ + apt-get install --no-install-recommends -y -q \ + build-essential ca-certificates \ + python python-pip python-dev \ + libffi-dev libssl-dev \ + libxml2-dev libxslt1-dev zlib1g-dev \ + git sudo curl && \ + pip install --upgrade setuptools pip wheel && \ + pip install --upgrade cffi pywinrm && \ + pip install --upgrade pyyaml jinja2 pycrypto && \ + \ + \ + echo "===> Downloading Ansible's source tree..." && \ + git clone git://github.com/ansible/ansible.git --recursive && \ + \ + \ + echo "===> Compiling Ansible..." && \ + cd ansible && \ + bash -c 'source ./hacking/env-setup' && \ + \ + \ + echo "===> Moving useful Ansible stuff to /opt/ansible ..." && \ + mkdir -p /opt/ansible && \ + mv /ansible/bin /opt/ansible/bin && \ + mv /ansible/lib /opt/ansible/lib && \ + mv /ansible/docs /opt/ansible/docs && \ + rm -rf /ansible && \ + \ + \ + echo "===> Installing handy tools (not absolutely required)..." && \ + + apt-get install -y sshpass openssh-client && \ + \ + \ + echo "===> Clean up..." && \ + apt-get remove -y --auto-remove \ + build-essential python-pip python-dev git libffi-dev libssl-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* && \ + \ + \ + echo "===> Adding hosts for convenience..." && \ + mkdir -p /etc/ansible && \ + echo 'localhost' > /etc/ansible/hosts + + +ENV PATH /opt/ansible/bin:$PATH +ENV PYTHONPATH /opt/ansible/lib:$PYTHONPATH +ENV MANPATH /opt/ansible/docs/man:$MANPATH + + +# default command: display Ansible version +CMD [ "ansible-playbook", "--version" ] diff --git a/mini-debian8/install-ansible.sh b/mini-debian8/install-ansible.sh index 6ddf0cb..b3c0dee 100755 --- a/mini-debian8/install-ansible.sh +++ b/mini-debian8/install-ansible.sh @@ -4,6 +4,9 @@ # +export DEBIAN_FRONTEND=noninteractive + + echo "===> Adding backports..." mkdir -p /etc/apt/sources.list.d/ diff --git a/mini-debian9/Dockerfile b/mini-debian9/Dockerfile new file mode 100644 index 0000000..8de9dd0 --- /dev/null +++ b/mini-debian9/Dockerfile @@ -0,0 +1,27 @@ +# 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:9 + +MAINTAINER William Yeh + +#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 diff --git a/mini-debian9/ansible-playbook-wrapper b/mini-debian9/ansible-playbook-wrapper new file mode 100755 index 0000000..0ba45e6 --- /dev/null +++ b/mini-debian9/ansible-playbook-wrapper @@ -0,0 +1,49 @@ +#!/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 diff --git a/mini-debian9/apt-list b/mini-debian9/apt-list new file mode 100644 index 0000000..7f23377 --- /dev/null +++ b/mini-debian9/apt-list @@ -0,0 +1,21 @@ +# +# 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 + +# may be required by ansible-galaxy +git \ No newline at end of file diff --git a/mini-debian9/install-ansible.sh b/mini-debian9/install-ansible.sh new file mode 100755 index 0000000..6083050 --- /dev/null +++ b/mini-debian9/install-ansible.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# +# Simple wrapper for installing ansible +# + + +export DEBIAN_FRONTEND=noninteractive + + +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 install -y ansible + + + +echo "===> Adding hosts for convenience..." && \ +mkdir -p /etc/ansible && \ +echo 'localhost' > /etc/ansible/hosts diff --git a/mini-debian9/prepare-pkg-list.sh b/mini-debian9/prepare-pkg-list.sh new file mode 100755 index 0000000..ce2195d --- /dev/null +++ b/mini-debian9/prepare-pkg-list.sh @@ -0,0 +1,37 @@ +#!/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 diff --git a/mini-debian9/uninstall-ansible.sh b/mini-debian9/uninstall-ansible.sh new file mode 100755 index 0000000..3573413 --- /dev/null +++ b/mini-debian9/uninstall-ansible.sh @@ -0,0 +1,21 @@ +#!/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/* diff --git a/mini-test/Dockerfile.debian9 b/mini-test/Dockerfile.debian9 new file mode 100644 index 0000000..786c74f --- /dev/null +++ b/mini-test/Dockerfile.debian9 @@ -0,0 +1,14 @@ +# Dockerfile for building (near-)minimal nginx under Debian9 +# + + +# pull base image +FROM ansible_mini_debian9 + +MAINTAINER William Yeh + +#ENV APK_LIST apk-list + +ENTRYPOINT ["/usr/sbin/nginx"] +#CMD ["-g", "daemon off;"] +CMD ["-v"] -- cgit v1.2.3