diff options
author | William Yeh <william.pjyeh@gmail.com> | 2015-04-28 23:38:41 +0800 |
---|---|---|
committer | William Yeh <william.pjyeh@gmail.com> | 2015-04-28 23:38:41 +0800 |
commit | 02c349017570070ead3755fe15c34d1661cee1e2 (patch) | |
tree | 80993bff0b3eee8d46509b5c23ec13cb24b2f75e | |
parent | e6ab6feafb044b0e22914243686b2d8cf245a869 (diff) | |
download | docker-ansible-02c349017570070ead3755fe15c34d1661cee1e2.tar.gz docker-ansible-02c349017570070ead3755fe15c34d1661cee1e2.tar.zst docker-ansible-02c349017570070ead3755fe15c34d1661cee1e2.zip |
Add: support for CentOS 7.
-rw-r--r-- | .travis.yml | 32 | ||||
-rw-r--r-- | README.md | 9 | ||||
-rw-r--r-- | Vagrantfile | 4 | ||||
-rw-r--r-- | centos7-onbuild/Dockerfile | 50 | ||||
-rwxr-xr-x | centos7-onbuild/ansible-playbook-wrapper | 30 | ||||
-rw-r--r-- | centos7/Dockerfile | 43 |
6 files changed, 165 insertions, 3 deletions
diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..89981bb --- /dev/null +++ b/.travis.yml | |||
@@ -0,0 +1,32 @@ | |||
1 | install: | ||
2 | - curl -sLo - https://github.com/moul/travis-docker/raw/master/install.sh | sh -xe | ||
3 | |||
4 | script: | ||
5 | - echo "==> Building the main Docker images..." | ||
6 | - ./run 'docker build -f centos6/Dockerfile -t ansible centos6 && docker run -i ansible > result-centos6' | ||
7 | - ./run 'docker build -f centos7/Dockerfile -t ansible centos7 && docker run -i ansible > result-centos7' | ||
8 | - ./run 'docker build -f debian7/Dockerfile -t ansible debian7 && docker run -i ansible > result-debian7' | ||
9 | - ./run 'docker build -f debian8/Dockerfile -t ansible debian8 && docker run -i ansible > result-debian8' | ||
10 | - ./run 'docker build -f ubuntu12.04/Dockerfile -t ansible ubuntu12.04 && docker run -i ansible > result-ubuntu12.04' | ||
11 | - ./run 'docker build -f ubuntu14.04/Dockerfile -t ansible ubuntu14.04 && docker run -i ansible > result-ubuntu14.04' | ||
12 | - ./run 'docker build -f centos6-onbuild/Dockerfile -t ansible centos6-onbuild && docker run -i ansible > result-centos6-onbuild' | ||
13 | - ./run 'docker build -f centos7-onbuild/Dockerfile -t ansible centos7-onbuild && docker run -i ansible > result-centos7-onbuild' | ||
14 | - ./run 'docker build -f debian7-onbuild/Dockerfile -t ansible debian7-onbuild && docker run -i ansible > result-debian7-onbuild' | ||
15 | - ./run 'docker build -f debian8-onbuild/Dockerfile -t ansible debian8-onbuild && docker run -i ansible > result-debian8-onbuild' | ||
16 | - ./run 'docker build -f ubuntu12.04-onbuild/Dockerfile -t ansible ubuntu12.04-onbuild && docker run -i ansible > result-ubuntu12.04-onbuild' | ||
17 | - ./run 'docker build -f ubuntu14.04-onbuild/Dockerfile -t ansible ubuntu14.04-onbuild && docker run -i ansible > result-ubuntu14.04-onbuild' | ||
18 | |||
19 | |||
20 | - echo "==> Validating the test results..." | ||
21 | - grep '^ansible-playbook' result-centos6 || exit 1 | ||
22 | - grep '^ansible-playbook' result-centos7 || exit 1 | ||
23 | - grep '^ansible-playbook' result-debian7 || exit 1 | ||
24 | - grep '^ansible-playbook' result-debian8 || exit 1 | ||
25 | - grep '^ansible-playbook' result-ubuntu12.04 || exit 1 | ||
26 | - grep '^ansible-playbook' result-ubuntu14.04 || exit 1 | ||
27 | - grep '^ansible-playbook' result-centos6-onbuild || exit 1 | ||
28 | - grep '^ansible-playbook' result-centos7-onbuild || exit 1 | ||
29 | - grep '^ansible-playbook' result-debian7-onbuild || exit 1 | ||
30 | - grep '^ansible-playbook' result-debian8-onbuild || exit 1 | ||
31 | - grep '^ansible-playbook' result-ubuntu12.04-onbuild || exit 1 | ||
32 | - grep '^ansible-playbook' result-ubuntu14.04-onbuild || exit 1 | ||
@@ -1,6 +1,8 @@ | |||
1 | Docker-Ansible base images | 1 | Docker-Ansible base images |
2 | =================== | 2 | =================== |
3 | 3 | ||
4 | [![Build Status](https://travis-ci.org/William-Yeh/docker-ansible.svg?branch=master)](https://travis-ci.org/William-Yeh/docker-ansible) | ||
5 | |||
4 | 6 | ||
5 | ## Summary | 7 | ## Summary |
6 | 8 | ||
@@ -14,7 +16,7 @@ This repository contains Dockerized [Ansible](https://github.com/ansible/ansible | |||
14 | 16 | ||
15 | These are Docker images for [Ansible](https://github.com/ansible/ansible) software, installed in a selected Linux distributions. | 17 | These are Docker images for [Ansible](https://github.com/ansible/ansible) software, installed in a selected Linux distributions. |
16 | 18 | ||
17 | - OS: Debian (jessie, wheezy), Ubuntu (trusty, precise), CentOS (6) | 19 | - OS: Debian (jessie, wheezy), Ubuntu (trusty, precise), CentOS (7, 6) |
18 | 20 | ||
19 | - Ansible: usually the latest version. | 21 | - Ansible: usually the latest version. |
20 | 22 | ||
@@ -27,6 +29,7 @@ These are Docker images for [Ansible](https://github.com/ansible/ansible) softwa | |||
27 | - `williamyeh/ansible:debian7` | 29 | - `williamyeh/ansible:debian7` |
28 | - `williamyeh/ansible:ubuntu14.04` | 30 | - `williamyeh/ansible:ubuntu14.04` |
29 | - `williamyeh/ansible:ubuntu12.04` | 31 | - `williamyeh/ansible:ubuntu12.04` |
32 | - `williamyeh/ansible:centos7` | ||
30 | - `williamyeh/ansible:centos6` | 33 | - `williamyeh/ansible:centos6` |
31 | 34 | ||
32 | - onbuild series: | 35 | - onbuild series: |
@@ -35,6 +38,7 @@ These are Docker images for [Ansible](https://github.com/ansible/ansible) softwa | |||
35 | - `williamyeh/ansible:debian7-onbuild` | 38 | - `williamyeh/ansible:debian7-onbuild` |
36 | - `williamyeh/ansible:ubuntu14.04-onbuild` | 39 | - `williamyeh/ansible:ubuntu14.04-onbuild` |
37 | - `williamyeh/ansible:ubuntu12.04-onbuild` | 40 | - `williamyeh/ansible:ubuntu12.04-onbuild` |
41 | - `williamyeh/ansible:centos7-onbuild` | ||
38 | - `williamyeh/ansible:centos6-onbuild` | 42 | - `williamyeh/ansible:centos6-onbuild` |
39 | 43 | ||
40 | 44 | ||
@@ -66,6 +70,7 @@ Vagrant.configure(2) do |config| | |||
66 | config.vm.box = "ubuntu/trusty64" | 70 | config.vm.box = "ubuntu/trusty64" |
67 | #config.vm.box = "hashicorp/precise64" | 71 | #config.vm.box = "hashicorp/precise64" |
68 | #config.vm.box = "chef/debian-7.8" | 72 | #config.vm.box = "chef/debian-7.8" |
73 | #config.vm.box = "chef/centos-7.0" | ||
69 | #config.vm.box = "chef/centos-6.6" | 74 | #config.vm.box = "chef/centos-6.6" |
70 | 75 | ||
71 | 76 | ||
@@ -91,6 +96,7 @@ FROM williamyeh/ansible:ubuntu14.04 | |||
91 | #FROM williamyeh/ansible:ubuntu12.04 | 96 | #FROM williamyeh/ansible:ubuntu12.04 |
92 | #FROM williamyeh/ansible:debian8 | 97 | #FROM williamyeh/ansible:debian8 |
93 | #FROM williamyeh/ansible:debian7 | 98 | #FROM williamyeh/ansible:debian7 |
99 | #FROM williamyeh/ansible:centos7 | ||
94 | #FROM williamyeh/ansible:centos6 | 100 | #FROM williamyeh/ansible:centos6 |
95 | 101 | ||
96 | 102 | ||
@@ -116,6 +122,7 @@ FROM williamyeh/ansible:ubuntu14.04-onbuild | |||
116 | #FROM williamyeh/ansible:ubuntu12.04-onbuild | 122 | #FROM williamyeh/ansible:ubuntu12.04-onbuild |
117 | #FROM williamyeh/ansible:debian8-onbuild | 123 | #FROM williamyeh/ansible:debian8-onbuild |
118 | #FROM williamyeh/ansible:debian7-onbuild | 124 | #FROM williamyeh/ansible:debian7-onbuild |
125 | #FROM williamyeh/ansible:centos7-onbuild | ||
119 | #FROM williamyeh/ansible:centos6-onbuild | 126 | #FROM williamyeh/ansible:centos6-onbuild |
120 | 127 | ||
121 | 128 | ||
diff --git a/Vagrantfile b/Vagrantfile index 1f16b40..9e3514b 100644 --- a/Vagrantfile +++ b/Vagrantfile | |||
@@ -8,14 +8,14 @@ Vagrant.configure(2) do |config| | |||
8 | docker build -t ansible:ubuntu12.04 ubuntu12.04 | 8 | docker build -t ansible:ubuntu12.04 ubuntu12.04 |
9 | docker build -t ansible:debian8 debian8 | 9 | docker build -t ansible:debian8 debian8 |
10 | docker build -t ansible:debian7 debian7 | 10 | docker build -t ansible:debian7 debian7 |
11 | #docker build -t ansible:centos7 centos7 | 11 | docker build -t ansible:centos7 centos7 |
12 | docker build -t ansible:centos6 centos6 | 12 | docker build -t ansible:centos6 centos6 |
13 | 13 | ||
14 | docker build -t ansible:ubuntu14.04-onbuild ubuntu14.04-onbuild | 14 | docker build -t ansible:ubuntu14.04-onbuild ubuntu14.04-onbuild |
15 | docker build -t ansible:ubuntu12.04-onbuild ubuntu12.04-onbuild | 15 | docker build -t ansible:ubuntu12.04-onbuild ubuntu12.04-onbuild |
16 | docker build -t ansible:debian8-onbuild debian8-onbuild | 16 | docker build -t ansible:debian8-onbuild debian8-onbuild |
17 | docker build -t ansible:debian7-onbuild debian7-onbuild | 17 | docker build -t ansible:debian7-onbuild debian7-onbuild |
18 | #docker build -t ansible:centos7-onbuild centos7-onbuild | 18 | docker build -t ansible:centos7-onbuild centos7-onbuild |
19 | docker build -t ansible:centos6-onbuild centos6-onbuild | 19 | docker build -t ansible:centos6-onbuild centos6-onbuild |
20 | 20 | ||
21 | SHELL | 21 | SHELL |
diff --git a/centos7-onbuild/Dockerfile b/centos7-onbuild/Dockerfile new file mode 100644 index 0000000..d668cba --- /dev/null +++ b/centos7-onbuild/Dockerfile | |||
@@ -0,0 +1,50 @@ | |||
1 | # Dockerfile for building Ansible image for CentOS 7, with as few additional software as possible. | ||
2 | # | ||
3 | # @see http://docs.ansible.com/intro_installation.html#latest-release-via-yum | ||
4 | # | ||
5 | # [NOTE] To fix the "sudo: sorry, you must have a tty to run sudo" issue, | ||
6 | # we need to patch /etc/sudoers. | ||
7 | # @see http://unix.stackexchange.com/questions/122616/why-do-i-need-a-tty-to-run-sudo-if-i-can-sudo-without-a-password | ||
8 | # @see https://bugzilla.redhat.com/show_bug.cgi?id=1020147 | ||
9 | # | ||
10 | # Version 1.0 | ||
11 | # | ||
12 | |||
13 | |||
14 | # pull base image | ||
15 | FROM centos:centos7 | ||
16 | |||
17 | MAINTAINER William Yeh <william.pjyeh@gmail.com> | ||
18 | |||
19 | |||
20 | RUN echo "===> Installing EPEL..." && \ | ||
21 | yum -y install epel-release && \ | ||
22 | \ | ||
23 | \ | ||
24 | echo "===> Installing Ansible..." && \ | ||
25 | yum -y install ansible sudo && \ | ||
26 | \ | ||
27 | \ | ||
28 | echo "===> Disabling sudo 'requiretty' setting..." && \ | ||
29 | sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers && \ | ||
30 | \ | ||
31 | \ | ||
32 | echo "===> Removing unused YUM resources..." && \ | ||
33 | yum -y remove epel-release && \ | ||
34 | yum clean all && \ | ||
35 | \ | ||
36 | \ | ||
37 | echo "===> Adding hosts for convenience..." && \ | ||
38 | mkdir -p /etc/ansible && \ | ||
39 | echo '[local]\nlocalhost\n' > /etc/ansible/hosts | ||
40 | |||
41 | |||
42 | COPY ansible-playbook-wrapper /usr/local/bin/ | ||
43 | |||
44 | ONBUILD WORKDIR /tmp | ||
45 | ONBUILD COPY . /tmp | ||
46 | |||
47 | |||
48 | |||
49 | # default command: display Ansible version | ||
50 | CMD [ "ansible-playbook", "--version" ] | ||
diff --git a/centos7-onbuild/ansible-playbook-wrapper b/centos7-onbuild/ansible-playbook-wrapper new file mode 100755 index 0000000..bf137c8 --- /dev/null +++ b/centos7-onbuild/ansible-playbook-wrapper | |||
@@ -0,0 +1,30 @@ | |||
1 | #!/bin/sh | ||
2 | # | ||
3 | # Simple wrapper for executing ansible-playbook with local connection. | ||
4 | # | ||
5 | # USAGE: | ||
6 | # ansible-playbook-wrapper [other ansible-playbook arguments] | ||
7 | # | ||
8 | # ENVIRONMENT VARIABLES: | ||
9 | # | ||
10 | # - PLAYBOOK: playbook filename; default = "playbook.yml" | ||
11 | # - INVENTORY: inventory filename; default = "/etc/ansible/hosts" | ||
12 | # | ||
13 | |||
14 | |||
15 | if [ -z "$PLAYBOOK" ]; then | ||
16 | PLAYBOOK=playbook.yml | ||
17 | fi | ||
18 | |||
19 | |||
20 | if [ -z "$INVENTORY" ]; then | ||
21 | exec ansible-playbook \ | ||
22 | $PLAYBOOK \ | ||
23 | --connection=local \ | ||
24 | "$@" | ||
25 | else | ||
26 | exec ansible-playbook \ | ||
27 | -i $INVENTORY $PLAYBOOK \ | ||
28 | --connection=local \ | ||
29 | "$@" | ||
30 | fi | ||
diff --git a/centos7/Dockerfile b/centos7/Dockerfile new file mode 100644 index 0000000..dd4b31c --- /dev/null +++ b/centos7/Dockerfile | |||
@@ -0,0 +1,43 @@ | |||
1 | # Dockerfile for building Ansible image for CentOS 7, with as few additional software as possible. | ||
2 | # | ||
3 | # @see http://docs.ansible.com/intro_installation.html#latest-release-via-yum | ||
4 | # | ||
5 | # [NOTE] To fix the "sudo: sorry, you must have a tty to run sudo" issue, | ||
6 | # we need to patch /etc/sudoers. | ||
7 | # @see http://unix.stackexchange.com/questions/122616/why-do-i-need-a-tty-to-run-sudo-if-i-can-sudo-without-a-password | ||
8 | # @see https://bugzilla.redhat.com/show_bug.cgi?id=1020147 | ||
9 | # | ||
10 | # Version 1.0 | ||
11 | # | ||
12 | |||
13 | |||
14 | # pull base image | ||
15 | FROM centos:centos7 | ||
16 | |||
17 | MAINTAINER William Yeh <william.pjyeh@gmail.com> | ||
18 | |||
19 | |||
20 | RUN echo "===> Installing EPEL..." && \ | ||
21 | yum -y install epel-release && \ | ||
22 | \ | ||
23 | \ | ||
24 | echo "===> Installing Ansible..." && \ | ||
25 | yum -y install ansible sudo && \ | ||
26 | \ | ||
27 | \ | ||
28 | echo "===> Disabling sudo 'requiretty' setting..." && \ | ||
29 | sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers && \ | ||
30 | \ | ||
31 | \ | ||
32 | echo "===> Removing unused YUM resources..." && \ | ||
33 | yum -y remove epel-release && \ | ||
34 | yum clean all && \ | ||
35 | \ | ||
36 | \ | ||
37 | echo "===> Adding hosts for convenience..." && \ | ||
38 | mkdir -p /etc/ansible && \ | ||
39 | echo '[local]\nlocalhost\n' > /etc/ansible/hosts | ||
40 | |||
41 | |||
42 | # default command: display Ansible version | ||
43 | CMD [ "ansible-playbook", "--version" ] | ||