From e6ab6feafb044b0e22914243686b2d8cf245a869 Mon Sep 17 00:00:00 2001 From: William Yeh Date: Tue, 28 Apr 2015 21:17:57 +0800 Subject: Add: support for CentOS 6. --- README.md | 8 ++++- Vagrantfile | 4 +++ centos6-onbuild/Dockerfile | 50 ++++++++++++++++++++++++++++++++ centos6-onbuild/ansible-playbook-wrapper | 30 +++++++++++++++++++ centos6/Dockerfile | 43 +++++++++++++++++++++++++++ 5 files changed, 134 insertions(+), 1 deletion(-) create mode 100644 centos6-onbuild/Dockerfile create mode 100755 centos6-onbuild/ansible-playbook-wrapper create mode 100644 centos6/Dockerfile diff --git a/README.md b/README.md index 7dce9f8..629ed7a 100644 --- 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" diff --git a/Vagrantfile b/Vagrantfile index 4d8c0a6..1f16b40 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -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 index 0000000..cb96493 --- /dev/null +++ b/centos6-onbuild/Dockerfile @@ -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 + + +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 index 0000000..bf137c8 --- /dev/null +++ b/centos6-onbuild/ansible-playbook-wrapper @@ -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 index 0000000..9a11b01 --- /dev/null +++ b/centos6/Dockerfile @@ -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 + + +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" ] -- cgit v1.2.3