]> git.immae.eu Git - github/fretlink/docker-ansible.git/commitdiff
Add: support for CentOS 6.
authorWilliam Yeh <william.pjyeh@gmail.com>
Tue, 28 Apr 2015 13:17:57 +0000 (21:17 +0800)
committerWilliam Yeh <william.pjyeh@gmail.com>
Tue, 28 Apr 2015 13:17:57 +0000 (21:17 +0800)
README.md
Vagrantfile
centos6-onbuild/Dockerfile [new file with mode: 0644]
centos6-onbuild/ansible-playbook-wrapper [new file with mode: 0755]
centos6/Dockerfile [new file with mode: 0644]

index 7dce9f86d1058a6dfb3b146c92c07ba46c04b3fa..629ed7a0cdc26b60d706bbdf16fa105eb101916f 100644 (file)
--- a/README.md
+++ b/README.md
@@ -14,7 +14,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).
+- OS: Debian (jessie, wheezy), Ubuntu (trusty, precise), CentOS (6)
 
 - Ansible: usually the latest version.
 
@@ -27,6 +27,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:centos6`
 
 - onbuild series:
 
@@ -34,6 +35,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:centos6-onbuild`
 
 
 ## Why yet another Ansible image for Docker?
@@ -64,6 +66,8 @@ 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-6.6"
+
 
     # ==> Executing Ansible...
     config.vm.provision "ansible" do |ansible|
@@ -87,6 +91,7 @@ FROM williamyeh/ansible:ubuntu14.04
 #FROM williamyeh/ansible:ubuntu12.04
 #FROM williamyeh/ansible:debian8
 #FROM williamyeh/ansible:debian7
+#FROM williamyeh/ansible:centos6
 
 
 # ==> Copying Ansible playbook...
@@ -111,6 +116,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:centos6-onbuild
 
 
 # ==> Specify playbook filename;   default = "playbook.yml"
index 4d8c0a6a737bfe400d50c2265adc610ec51a3a0f..1f16b40befa9142619ebfb0c43eeffd809e647fb 100644 (file)
@@ -8,11 +8,15 @@ 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: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:centos6-onbuild      centos6-onbuild
 
   SHELL
 end
diff --git a/centos6-onbuild/Dockerfile b/centos6-onbuild/Dockerfile
new file mode 100644 (file)
index 0000000..cb96493
--- /dev/null
@@ -0,0 +1,50 @@
+# Dockerfile for building Ansible image for CentOS 6, 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:centos6
+
+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/centos6-onbuild/ansible-playbook-wrapper b/centos6-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/centos6/Dockerfile b/centos6/Dockerfile
new file mode 100644 (file)
index 0000000..9a11b01
--- /dev/null
@@ -0,0 +1,43 @@
+# Dockerfile for building Ansible image for CentOS 6, 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:centos6
+
+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" ]