]> git.immae.eu Git - github/fretlink/docker-ansible.git/commitdiff
Add: support for CentOS 7.
authorWilliam Yeh <william.pjyeh@gmail.com>
Tue, 28 Apr 2015 15:38:41 +0000 (23:38 +0800)
committerWilliam Yeh <william.pjyeh@gmail.com>
Tue, 28 Apr 2015 15:38:41 +0000 (23:38 +0800)
.travis.yml [new file with mode: 0644]
README.md
Vagrantfile
centos7-onbuild/Dockerfile [new file with mode: 0644]
centos7-onbuild/ansible-playbook-wrapper [new file with mode: 0755]
centos7/Dockerfile [new file with mode: 0644]

diff --git a/.travis.yml b/.travis.yml
new file mode 100644 (file)
index 0000000..89981bb
--- /dev/null
@@ -0,0 +1,32 @@
+install:
+  - curl -sLo - https://github.com/moul/travis-docker/raw/master/install.sh | sh -xe
+
+script:
+  - echo "==> Building the main Docker images..."
+  - ./run 'docker build -f centos6/Dockerfile      -t ansible  centos6      &&  docker run -i ansible > result-centos6'
+  - ./run 'docker build -f centos7/Dockerfile      -t ansible  centos7      &&  docker run -i ansible > result-centos7'
+  - ./run 'docker build -f debian7/Dockerfile      -t ansible  debian7      &&  docker run -i ansible > result-debian7'
+  - ./run 'docker build -f debian8/Dockerfile      -t ansible  debian8      &&  docker run -i ansible > result-debian8'
+  - ./run 'docker build -f ubuntu12.04/Dockerfile  -t ansible  ubuntu12.04  &&  docker run -i ansible > result-ubuntu12.04'
+  - ./run 'docker build -f ubuntu14.04/Dockerfile  -t ansible  ubuntu14.04  &&  docker run -i ansible > result-ubuntu14.04'
+  - ./run 'docker build -f centos6-onbuild/Dockerfile      -t ansible  centos6-onbuild      &&  docker run -i ansible > result-centos6-onbuild'
+  - ./run 'docker build -f centos7-onbuild/Dockerfile      -t ansible  centos7-onbuild      &&  docker run -i ansible > result-centos7-onbuild'
+  - ./run 'docker build -f debian7-onbuild/Dockerfile      -t ansible  debian7-onbuild      &&  docker run -i ansible > result-debian7-onbuild'
+  - ./run 'docker build -f debian8-onbuild/Dockerfile      -t ansible  debian8-onbuild      &&  docker run -i ansible > result-debian8-onbuild'
+  - ./run 'docker build -f ubuntu12.04-onbuild/Dockerfile  -t ansible  ubuntu12.04-onbuild  &&  docker run -i ansible > result-ubuntu12.04-onbuild'
+  - ./run 'docker build -f ubuntu14.04-onbuild/Dockerfile  -t ansible  ubuntu14.04-onbuild  &&  docker run -i ansible > result-ubuntu14.04-onbuild'
+
+
+  - echo "==> Validating the test results..."
+  - grep '^ansible-playbook' result-centos6      ||  exit 1
+  - grep '^ansible-playbook' result-centos7      ||  exit 1
+  - grep '^ansible-playbook' result-debian7      ||  exit 1
+  - grep '^ansible-playbook' result-debian8      ||  exit 1
+  - grep '^ansible-playbook' result-ubuntu12.04  ||  exit 1
+  - grep '^ansible-playbook' result-ubuntu14.04  ||  exit 1
+  - grep '^ansible-playbook' result-centos6-onbuild      ||  exit 1
+  - grep '^ansible-playbook' result-centos7-onbuild      ||  exit 1
+  - grep '^ansible-playbook' result-debian7-onbuild      ||  exit 1
+  - grep '^ansible-playbook' result-debian8-onbuild      ||  exit 1
+  - grep '^ansible-playbook' result-ubuntu12.04-onbuild  ||  exit 1
+  - grep '^ansible-playbook' result-ubuntu14.04-onbuild  ||  exit 1
index 629ed7a0cdc26b60d706bbdf16fa105eb101916f..62d511944b8a1277e499f94c8033cfc32cc1569c 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,6 +1,8 @@
 Docker-Ansible base images
 ===================
 
+[![Build Status](https://travis-ci.org/William-Yeh/docker-ansible.svg?branch=master)](https://travis-ci.org/William-Yeh/docker-ansible)
+
 
 ## Summary
 
@@ -14,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 (6)
+- OS: Debian (jessie, wheezy), Ubuntu (trusty, precise), CentOS (7, 6)
 
 - Ansible: usually the latest version.
 
@@ -27,6 +29,7 @@ These are Docker images for [Ansible](https://github.com/ansible/ansible) softwa
   - `williamyeh/ansible:debian7`
   - `williamyeh/ansible:ubuntu14.04`
   - `williamyeh/ansible:ubuntu12.04`
+  - `williamyeh/ansible:centos7`
   - `williamyeh/ansible:centos6`
 
 - onbuild series:
@@ -35,6 +38,7 @@ These are Docker images for [Ansible](https://github.com/ansible/ansible) softwa
   - `williamyeh/ansible:debian7-onbuild`
   - `williamyeh/ansible:ubuntu14.04-onbuild`
   - `williamyeh/ansible:ubuntu12.04-onbuild`
+  - `williamyeh/ansible:centos7-onbuild`
   - `williamyeh/ansible:centos6-onbuild`
 
 
@@ -66,6 +70,7 @@ Vagrant.configure(2) do |config|
     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"
 
 
@@ -91,6 +96,7 @@ FROM williamyeh/ansible:ubuntu14.04
 #FROM williamyeh/ansible:ubuntu12.04
 #FROM williamyeh/ansible:debian8
 #FROM williamyeh/ansible:debian7
+#FROM williamyeh/ansible:centos7
 #FROM williamyeh/ansible:centos6
 
 
@@ -116,6 +122,7 @@ FROM williamyeh/ansible:ubuntu14.04-onbuild
 #FROM williamyeh/ansible:ubuntu12.04-onbuild
 #FROM williamyeh/ansible:debian8-onbuild
 #FROM williamyeh/ansible:debian7-onbuild
+#FROM williamyeh/ansible:centos7-onbuild
 #FROM williamyeh/ansible:centos6-onbuild
 
 
index 1f16b40befa9142619ebfb0c43eeffd809e647fb..9e3514bfccc2445d9ff48c93aabb5e0e2b094ca8 100644 (file)
@@ -8,14 +8,14 @@ Vagrant.configure(2) do |config|
     docker build  -t ansible:ubuntu12.04  ubuntu12.04
     docker build  -t ansible:debian8      debian8
     docker build  -t ansible:debian7      debian7
-    #docker build  -t ansible:centos7      centos7
+    docker build  -t ansible:centos7      centos7
     docker build  -t ansible:centos6      centos6
 
     docker build  -t ansible:ubuntu14.04-onbuild  ubuntu14.04-onbuild
     docker build  -t ansible:ubuntu12.04-onbuild  ubuntu12.04-onbuild
     docker build  -t ansible:debian8-onbuild      debian8-onbuild
     docker build  -t ansible:debian7-onbuild      debian7-onbuild
-    #docker build  -t ansible:centos7-onbuild      centos7-onbuild
+    docker build  -t ansible:centos7-onbuild      centos7-onbuild
     docker build  -t ansible:centos6-onbuild      centos6-onbuild
 
   SHELL
diff --git a/centos7-onbuild/Dockerfile b/centos7-onbuild/Dockerfile
new file mode 100644 (file)
index 0000000..d668cba
--- /dev/null
@@ -0,0 +1,50 @@
+# Dockerfile for building Ansible image for CentOS 7, with as few additional software as possible.
+#
+# @see http://docs.ansible.com/intro_installation.html#latest-release-via-yum
+#
+# [NOTE] To fix the "sudo: sorry, you must have a tty to run sudo" issue,
+#        we need to patch /etc/sudoers.
+#        @see http://unix.stackexchange.com/questions/122616/why-do-i-need-a-tty-to-run-sudo-if-i-can-sudo-without-a-password
+#        @see https://bugzilla.redhat.com/show_bug.cgi?id=1020147
+#
+# Version  1.0
+#
+
+
+# pull base image
+FROM centos:centos7
+
+MAINTAINER William Yeh <william.pjyeh@gmail.com>
+
+
+RUN echo "===> Installing EPEL..."        && \
+    yum -y install epel-release           && \
+    \
+    \
+    echo "===> Installing Ansible..."     && \
+    yum -y install ansible sudo           && \
+    \
+    \
+    echo "===> Disabling sudo 'requiretty' setting..."    && \
+    sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/'  /etc/sudoers   && \
+    \
+    \
+    echo "===> Removing unused YUM resources..."   && \
+    yum -y remove epel-release                     && \
+    yum clean all                                  && \
+    \
+    \
+    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
+
+
+
+# default command: display Ansible version
+CMD [ "ansible-playbook", "--version" ]
diff --git a/centos7-onbuild/ansible-playbook-wrapper b/centos7-onbuild/ansible-playbook-wrapper
new file mode 100755 (executable)
index 0000000..bf137c8
--- /dev/null
@@ -0,0 +1,30 @@
+#!/bin/sh
+#
+# Simple wrapper for executing ansible-playbook with local connection.
+#
+# USAGE:
+#    ansible-playbook-wrapper  [other ansible-playbook arguments]
+#
+# ENVIRONMENT VARIABLES:
+# 
+#    - PLAYBOOK: playbook filename;   default = "playbook.yml"
+#    - INVENTORY: inventory filename; default = "/etc/ansible/hosts"
+# 
+
+
+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/centos7/Dockerfile b/centos7/Dockerfile
new file mode 100644 (file)
index 0000000..dd4b31c
--- /dev/null
@@ -0,0 +1,43 @@
+# Dockerfile for building Ansible image for CentOS 7, with as few additional software as possible.
+#
+# @see http://docs.ansible.com/intro_installation.html#latest-release-via-yum
+#
+# [NOTE] To fix the "sudo: sorry, you must have a tty to run sudo" issue,
+#        we need to patch /etc/sudoers.
+#        @see http://unix.stackexchange.com/questions/122616/why-do-i-need-a-tty-to-run-sudo-if-i-can-sudo-without-a-password
+#        @see https://bugzilla.redhat.com/show_bug.cgi?id=1020147
+#
+# Version  1.0
+#
+
+
+# pull base image
+FROM centos:centos7
+
+MAINTAINER William Yeh <william.pjyeh@gmail.com>
+
+
+RUN echo "===> Installing EPEL..."        && \
+    yum -y install epel-release           && \
+    \
+    \
+    echo "===> Installing Ansible..."     && \
+    yum -y install ansible sudo           && \
+    \
+    \
+    echo "===> Disabling sudo 'requiretty' setting..."    && \
+    sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/'  /etc/sudoers   && \
+    \
+    \
+    echo "===> Removing unused YUM resources..."   && \
+    yum -y remove epel-release                     && \
+    yum clean all                                  && \
+    \
+    \
+    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" ]