]> git.immae.eu Git - github/fretlink/docker-ansible.git/commitdiff
Add: `mini-debian8` tag.
authorWilliam Yeh <william.pjyeh@gmail.com>
Thu, 2 Jun 2016 08:07:46 +0000 (16:07 +0800)
committerWilliam Yeh <william.pjyeh@gmail.com>
Thu, 2 Jun 2016 08:07:46 +0000 (16:07 +0800)
12 files changed:
.travis.yml
README.md
circle.yml
mini-debian8/Dockerfile [new file with mode: 0644]
mini-debian8/ansible-playbook-wrapper [new file with mode: 0755]
mini-debian8/apt-list [new file with mode: 0644]
mini-debian8/install-ansible.sh [new file with mode: 0755]
mini-debian8/prepare-pkg-list.sh [new file with mode: 0755]
mini-debian8/uninstall-ansible.sh [new file with mode: 0755]
mini-test/Dockerfile.alpine3
mini-test/Dockerfile.debian8 [new file with mode: 0644]
mini-test/playbook.yml

index ea6cc78064639efdb6cf530d2d1f42a96087d797..ac9983b8a7cd78a3c819dc80beb829a6f10c74ee 100644 (file)
@@ -59,8 +59,10 @@ before_install:
     - 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:
@@ -114,7 +116,8 @@ 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..."
@@ -166,3 +169,4 @@ script:
     - sh -c "[ -s result-master-centos6-onbuild     ]"
 
     - sh -c "[ -s result-nginx-alpine3     ]"
+    - sh -c "[ -s result-nginx-debian8     ]"
index 8abe0cc03cf80ffc03f94fcf77275a57ab92eeb8..d982543b0c3d8d15eac9a2dfaac411d9f4e47552 100644 (file)
--- a/README.md
+++ b/README.md
@@ -102,6 +102,7 @@ These are Docker images for [Ansible](https://github.com/ansible/ansible) softwa
 - Onbuild series:
 
   - `williamyeh/ansible:mini-alpine3`
+  - `williamyeh/ansible:mini-debian8`
 
 
 
index 9fc121f3dc736f054a627ff45b12dc9f9335b187..18e525362dd2f3503177cfb2226232ad9b5aa007 100644 (file)
@@ -60,8 +60,10 @@ dependencies:
     - 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:
@@ -116,7 +118,8 @@ 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..."
@@ -168,3 +171,4 @@ test:
     - sh -c "[ -s result-master-centos6-onbuild     ]"
 
     - sh -c "[ -s result-nginx-alpine3     ]"
+    - sh -c "[ -s result-nginx-debian8     ]"
diff --git a/mini-debian8/Dockerfile b/mini-debian8/Dockerfile
new file mode 100644 (file)
index 0000000..d45d4e6
--- /dev/null
@@ -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: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
diff --git a/mini-debian8/ansible-playbook-wrapper b/mini-debian8/ansible-playbook-wrapper
new file mode 100755 (executable)
index 0000000..0ba45e6
--- /dev/null
@@ -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-debian8/apt-list b/mini-debian8/apt-list
new file mode 100644 (file)
index 0000000..635e7d5
--- /dev/null
@@ -0,0 +1,18 @@
+#
+# 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
diff --git a/mini-debian8/install-ansible.sh b/mini-debian8/install-ansible.sh
new file mode 100755 (executable)
index 0000000..6ddf0cb
--- /dev/null
@@ -0,0 +1,31 @@
+#!/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
diff --git a/mini-debian8/prepare-pkg-list.sh b/mini-debian8/prepare-pkg-list.sh
new file mode 100755 (executable)
index 0000000..ce2195d
--- /dev/null
@@ -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-debian8/uninstall-ansible.sh b/mini-debian8/uninstall-ansible.sh
new file mode 100755 (executable)
index 0000000..3573413
--- /dev/null
@@ -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/*
index 78e752163390094e711decec29d2d6a7208dda96..a42fa33900b8457dfb603335cde1dcbfd795ddd3 100644 (file)
@@ -3,7 +3,7 @@
 
 
 # pull base image
-FROM ansible_mini_apline3
+FROM ansible_mini_alpine3
 
 MAINTAINER William Yeh <william.pjyeh@gmail.com>
 
diff --git a/mini-test/Dockerfile.debian8 b/mini-test/Dockerfile.debian8
new file mode 100644 (file)
index 0000000..f41cbbb
--- /dev/null
@@ -0,0 +1,14 @@
+# 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"]
index 898dfc5de6f8bfc478bbd021c24028d7d82467e9..b8cccda9033bd3c0e547b311b7d7500b2a707c71 100644 (file)
@@ -1,5 +1,18 @@
 - 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