From ae06b63dc27567ebe8b8fde7f32e268ae706182d Mon Sep 17 00:00:00 2001 From: William Yeh Date: Thu, 17 Sep 2015 15:26:56 +0800 Subject: Add: support for Alpine 3 --- .travis.yml | 6 ++++ README.md | 17 +++++++---- Vagrantfile | 2 ++ alpine3-onbuild/Dockerfile | 47 ++++++++++++++++++++++++++++++ alpine3-onbuild/ansible-playbook-wrapper | 49 ++++++++++++++++++++++++++++++++ alpine3/Dockerfile | 36 +++++++++++++++++++++++ circle.yml | 6 ++++ 7 files changed, 158 insertions(+), 5 deletions(-) create mode 100644 alpine3-onbuild/Dockerfile create mode 100755 alpine3-onbuild/ansible-playbook-wrapper create mode 100644 alpine3/Dockerfile diff --git a/.travis.yml b/.travis.yml index ad12eaa..06a51ce 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ before_install: - docker build -t ansible_wheezy debian7 - docker build -t ansible_centos7 centos7 - docker build -t ansible_centos6 centos6 + - docker build -t ansible_alpine3 alpine3 - docker build -t ansible_trusty_onbuild ubuntu14.04-onbuild - docker build -t ansible_precise_onbuild ubuntu12.04-onbuild @@ -19,6 +20,7 @@ before_install: - docker build -t ansible_wheezy_onbuild debian7-onbuild - docker build -t ansible_centos7_onbuild centos7-onbuild - docker build -t ansible_centos6_onbuild centos6-onbuild + - docker build -t ansible_alpine3_onbuild alpine3-onbuild script: - docker run -i ansible_trusty > result-ubuntu14.04 @@ -27,12 +29,14 @@ script: - docker run -i ansible_wheezy > result-debian7 - docker run -i ansible_centos7 > result-centos7 - docker run -i ansible_centos6 > result-centos6 + - docker run -i ansible_alpine3 > result-alpine3 - docker run -i ansible_trusty_onbuild > result-ubuntu14.04-onbuild - docker run -i ansible_precise_onbuild > result-ubuntu12.04-onbuild - docker run -i ansible_jessie_onbuild > result-debian8-onbuild - docker run -i ansible_wheezy_onbuild > result-debian7-onbuild - docker run -i ansible_centos7_onbuild > result-centos7-onbuild - docker run -i ansible_centos6_onbuild > result-centos6-onbuild + - docker run -i ansible_alpine3_onbuild > result-alpine3-onbuild - echo "==> Validating the test results..." - sh -c "[ -s result-ubuntu14.04 ]" @@ -41,9 +45,11 @@ script: - sh -c "[ -s result-debian7 ]" - sh -c "[ -s result-centos7 ]" - sh -c "[ -s result-centos6 ]" + - sh -c "[ -s result-alpine3 ]" - sh -c "[ -s result-ubuntu14.04-onbuild ]" - sh -c "[ -s result-ubuntu12.04-onbuild ]" - sh -c "[ -s result-debian8-onbuild ]" - sh -c "[ -s result-debian7-onbuild ]" - sh -c "[ -s result-centos7-onbuild ]" - sh -c "[ -s result-centos6-onbuild ]" + - sh -c "[ -s result-alpine3-onbuild ]" diff --git a/README.md b/README.md index 98db6ea..26f03d4 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ This repository contains Dockerized [Ansible](https://github.com/ansible/ansible These are Docker images for [Ansible](https://github.com/ansible/ansible) software, installed in a selected Linux distributions. -- OS: Debian (jessie, wheezy), Ubuntu (trusty, precise), CentOS (7, 6) +- OS: Debian (jessie, wheezy), Ubuntu (trusty, precise), CentOS (7, 6), Alpine (3). - Ansible: usually the latest version (I didn't pin any specific version). @@ -31,6 +31,7 @@ These are Docker images for [Ansible](https://github.com/ansible/ansible) softwa - `williamyeh/ansible:ubuntu12.04` - `williamyeh/ansible:centos7` - `williamyeh/ansible:centos6` + - `williamyeh/ansible:alpine3` - Onbuild series: @@ -40,6 +41,7 @@ These are Docker images for [Ansible](https://github.com/ansible/ansible) softwa - `williamyeh/ansible:ubuntu12.04-onbuild` - `williamyeh/ansible:centos7-onbuild` - `williamyeh/ansible:centos6-onbuild` + - `williamyeh/ansible:alpine3-onbuild` ## For the impatient @@ -97,6 +99,7 @@ REPOSITORY TAG VIRTUAL SIZE ansible/centos7-ansible stable 367.5 MB ansible/ubuntu14.04-ansible stable 286.6 MB +williamyeh/ansible alpine3-onbuild 66.4 MB williamyeh/ansible centos6-onbuild 264.2 MB williamyeh/ansible centos7-onbuild 275.3 MB williamyeh/ansible debian7-onbuild 134.4 MB @@ -119,10 +122,12 @@ Vagrant.configure(2) do |config| # ==> Choose a Vagrant box to emulate Linux distribution... config.vm.box = "ubuntu/trusty64" - #config.vm.box = "hashicorp/precise64" - #config.vm.box = "chef/debian-7.8" - #config.vm.box = "chef/centos-7.0" - #config.vm.box = "chef/centos-6.6" + #config.vm.box = "ubuntu/precise64" + #config.vm.box = "debian/jessie64" + #config.vm.box = "debian/wheezy64" + #config.vm.box = "bento/centos-7.1" + #config.vm.box = "bento/centos-6.7" + #config.vm.box = "maier/alpine-3.1.3-x86_64" # ==> Executing Ansible... @@ -149,6 +154,7 @@ FROM williamyeh/ansible:ubuntu14.04 #FROM williamyeh/ansible:debian7 #FROM williamyeh/ansible:centos7 #FROM williamyeh/ansible:centos6 +#FROM williamyeh/ansible:alpine3 # ==> Copying Ansible playbook... @@ -175,6 +181,7 @@ FROM williamyeh/ansible:ubuntu14.04-onbuild #FROM williamyeh/ansible:debian7-onbuild #FROM williamyeh/ansible:centos7-onbuild #FROM williamyeh/ansible:centos6-onbuild +#FROM williamyeh/ansible:alpine3-onbuild # ==> Specify requirements filename; default = "requirements.yml" diff --git a/Vagrantfile b/Vagrantfile index beac0fc..46458fb 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -10,6 +10,7 @@ Vagrant.configure(2) do |config| docker build -t ansible:debian7 debian7 docker build -t ansible:centos7 centos7 docker build -t ansible:centos6 centos6 + docker build -t ansible:alpine3 alpine3 docker build -t ansible:ubuntu14.04-onbuild ubuntu14.04-onbuild docker build -t ansible:ubuntu12.04-onbuild ubuntu12.04-onbuild @@ -17,6 +18,7 @@ Vagrant.configure(2) do |config| docker build -t ansible:debian7-onbuild debian7-onbuild docker build -t ansible:centos7-onbuild centos7-onbuild docker build -t ansible:centos6-onbuild centos6-onbuild + docker build -t ansible:alpine3-onbuild alpine3-onbuild SHELL end diff --git a/alpine3-onbuild/Dockerfile b/alpine3-onbuild/Dockerfile new file mode 100644 index 0000000..41d6fab --- /dev/null +++ b/alpine3-onbuild/Dockerfile @@ -0,0 +1,47 @@ +# Dockerfile for building Ansible image for Alpine 3, with as few additional software as possible. +# +# @see https://github.com/gliderlabs/docker-alpine/blob/master/docs/usage.md +# +# Version 1.0 +# + + +# pull base image +FROM alpine:3.2 + +MAINTAINER William Yeh + + +RUN echo "===> Adding Python runtime..." && \ + apk --update add python py-pip openssl ca-certificates && \ + apk --update add --virtual build-dependencies python-dev build-base && \ + pip install --upgrade pip && \ + \ + \ + echo "===> Installing Ansible..." && \ + pip install ansible && \ + \ + \ + echo "===> Removing package list..." && \ + apk del build-dependencies && \ + rm -rf /var/cache/apk/* && \ + \ + \ + echo "===> Adding hosts for convenience..." && \ + mkdir -p /etc/ansible && \ + echo '[local]\nlocalhost\n' > /etc/ansible/hosts + + +COPY ansible-playbook-wrapper /usr/local/bin/ + + +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/alpine3-onbuild/ansible-playbook-wrapper b/alpine3-onbuild/ansible-playbook-wrapper new file mode 100755 index 0000000..0ba45e6 --- /dev/null +++ b/alpine3-onbuild/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/alpine3/Dockerfile b/alpine3/Dockerfile new file mode 100644 index 0000000..04efa90 --- /dev/null +++ b/alpine3/Dockerfile @@ -0,0 +1,36 @@ +# Dockerfile for building Ansible image for Alpine 3, with as few additional software as possible. +# +# @see https://github.com/gliderlabs/docker-alpine/blob/master/docs/usage.md +# +# Version 1.0 +# + + +# pull base image +FROM alpine:3.2 + +MAINTAINER William Yeh + + +RUN echo "===> Adding Python runtime..." && \ + apk --update add python py-pip openssl ca-certificates && \ + apk --update add --virtual build-dependencies python-dev build-base && \ + pip install --upgrade pip && \ + \ + \ + echo "===> Installing Ansible..." && \ + pip install ansible && \ + \ + \ + echo "===> Removing package list..." && \ + apk del build-dependencies && \ + rm -rf /var/cache/apk/* && \ + \ + \ + echo "===> Adding hosts for convenience..." && \ + mkdir -p /etc/ansible && \ + echo '[local]\nlocalhost\n' > /etc/ansible/hosts + + +# default command: display Ansible version +CMD [ "ansible-playbook", "--version" ] diff --git a/circle.yml b/circle.yml index 6d69d2f..c979c1f 100644 --- a/circle.yml +++ b/circle.yml @@ -13,6 +13,7 @@ dependencies: - docker build -t ansible_wheezy debian7 - docker build -t ansible_centos7 centos7 - docker build -t ansible_centos6 centos6 + - docker build -t ansible_alpine3 alpine3 - docker build -t ansible_trusty_onbuild ubuntu14.04-onbuild - docker build -t ansible_precise_onbuild ubuntu12.04-onbuild @@ -20,6 +21,7 @@ dependencies: - docker build -t ansible_wheezy_onbuild debian7-onbuild - docker build -t ansible_centos7_onbuild centos7-onbuild - docker build -t ansible_centos6_onbuild centos6-onbuild + - docker build -t ansible_alpine3_onbuild alpine3-onbuild test: override: @@ -29,12 +31,14 @@ test: - docker run -i ansible_wheezy > result-debian7 - docker run -i ansible_centos7 > result-centos7 - docker run -i ansible_centos6 > result-centos6 + - docker run -i ansible_alpine3 > result-alpine3 - docker run -i ansible_trusty_onbuild > result-ubuntu14.04-onbuild - docker run -i ansible_precise_onbuild > result-ubuntu12.04-onbuild - docker run -i ansible_jessie_onbuild > result-debian8-onbuild - docker run -i ansible_wheezy_onbuild > result-debian7-onbuild - docker run -i ansible_centos7_onbuild > result-centos7-onbuild - docker run -i ansible_centos6_onbuild > result-centos6-onbuild + - docker run -i ansible_alpine3_onbuild > result-alpine3-onbuild - echo "==> Validating the test results..." - sh -c "[ -s result-ubuntu14.04 ]" @@ -43,9 +47,11 @@ test: - sh -c "[ -s result-debian7 ]" - sh -c "[ -s result-centos7 ]" - sh -c "[ -s result-centos6 ]" + - sh -c "[ -s result-alpine3 ]" - sh -c "[ -s result-ubuntu14.04-onbuild ]" - sh -c "[ -s result-ubuntu12.04-onbuild ]" - sh -c "[ -s result-debian8-onbuild ]" - sh -c "[ -s result-debian7-onbuild ]" - sh -c "[ -s result-centos7-onbuild ]" - sh -c "[ -s result-centos6-onbuild ]" + - sh -c "[ -s result-alpine3-onbuild ]" -- cgit v1.2.3