diff options
author | William Yeh <william.pjyeh@gmail.com> | 2015-04-29 11:49:55 +0800 |
---|---|---|
committer | William Yeh <william.pjyeh@gmail.com> | 2015-04-29 11:49:55 +0800 |
commit | c20fa4925201735909d587cd435561e2d3f5a52b (patch) | |
tree | bfb30c7105701a980d9e67a3fb3227d4d04e8480 | |
parent | 02c349017570070ead3755fe15c34d1661cee1e2 (diff) | |
download | docker-ansible-c20fa4925201735909d587cd435561e2d3f5a52b.tar.gz docker-ansible-c20fa4925201735909d587cd435561e2d3f5a52b.tar.zst docker-ansible-c20fa4925201735909d587cd435561e2d3f5a52b.zip |
Add: a simplest working example.
-rw-r--r-- | README.md | 49 | ||||
-rwxr-xr-x | compare-image-size.sh | 21 |
2 files changed, 69 insertions, 1 deletions
@@ -42,6 +42,36 @@ These are Docker images for [Ansible](https://github.com/ansible/ansible) softwa | |||
42 | - `williamyeh/ansible:centos6-onbuild` | 42 | - `williamyeh/ansible:centos6-onbuild` |
43 | 43 | ||
44 | 44 | ||
45 | ## For the impatient | ||
46 | |||
47 | Here comes a simplest working example for the impatient. | ||
48 | |||
49 | First, choose a base image you'd like to begin with. For example, `williamyeh/ansible:ubuntu14.04-onbuild`. | ||
50 | |||
51 | Second, put the following `Dockerfile` along with your playbook directory: | ||
52 | |||
53 | ``` | ||
54 | FROM williamyeh/ansible:ubuntu14.04-onbuild | ||
55 | |||
56 | # ==> Specify playbook filename; default = "playbook.yml" | ||
57 | #ENV PLAYBOOK playbook.yml | ||
58 | |||
59 | # ==> Specify inventory filename; default = "/etc/ansible/hosts" | ||
60 | #ENV INVENTORY inventory.ini | ||
61 | |||
62 | # ==> Executing Ansible... | ||
63 | RUN ansible-playbook-wrapper | ||
64 | ``` | ||
65 | |||
66 | Third, `docker build .` | ||
67 | |||
68 | Done! | ||
69 | |||
70 | For more advanced usage, the role in Ansible Galaxy [`williamyeh/nginx`](https://github.com/William-Yeh/ansible-nginx) also demonstrates how to do a simple integration test on [Travis CI](https://travis-ci.org/). | ||
71 | |||
72 | |||
73 | |||
74 | |||
45 | ## Why yet another Ansible image for Docker? | 75 | ## Why yet another Ansible image for Docker? |
46 | 76 | ||
47 | There has been quite a few Ansible images for Docker (e.g., [search](https://registry.hub.docker.com/search?q=ansible) in the Docker Hub), so why reinvent the wheel? | 77 | There has been quite a few Ansible images for Docker (e.g., [search](https://registry.hub.docker.com/search?q=ansible) in the Docker Hub), so why reinvent the wheel? |
@@ -55,11 +85,28 @@ In the beginning I used the [`ansible/ansible-docker-base`](https://github.com/a | |||
55 | Therefore, I built these Docker images on my own. | 85 | Therefore, I built these Docker images on my own. |
56 | 86 | ||
57 | 87 | ||
88 | ### Comparison: image size | ||
89 | |||
90 | ``` | ||
91 | REPOSITORY TAG VIRTUAL SIZE | ||
92 | --------------------------- ------------------- ------------ | ||
93 | ansible/centos7-ansible stable 367.5 MB | ||
94 | ansible/ubuntu14.04-ansible stable 286.6 MB | ||
95 | |||
96 | williamyeh/ansible centos6-onbuild 264.2 MB | ||
97 | williamyeh/ansible centos7-onbuild 275.3 MB | ||
98 | williamyeh/ansible debian7-onbuild 134.4 MB | ||
99 | williamyeh/ansible debian8-onbuild 178.3 MB | ||
100 | williamyeh/ansible ubuntu12.04-onbuild 181.9 MB | ||
101 | williamyeh/ansible ubuntu14.04-onbuild 238.3 MB | ||
102 | ``` | ||
103 | |||
104 | |||
58 | ## Usage | 105 | ## Usage |
59 | 106 | ||
60 | Used mostly as a *base image* for configuring, with Ansible, other software stack on some specified Linux distribution. | 107 | Used mostly as a *base image* for configuring, with Ansible, other software stack on some specified Linux distribution. |
61 | 108 | ||
62 | Take Debian/Ubuntu for example. To test an Ansible `playbook.yml` against a variety of Linux distributions, we may use [Vagrant](https://www.vagrantup.com/) as follows: | 109 | Take Debian/Ubuntu/CentOS for example. To test an Ansible `playbook.yml` against a variety of Linux distributions, we may use [Vagrant](https://www.vagrantup.com/) as follows: |
63 | 110 | ||
64 | ```ruby | 111 | ```ruby |
65 | # Vagrantfile | 112 | # Vagrantfile |
diff --git a/compare-image-size.sh b/compare-image-size.sh new file mode 100755 index 0000000..9c7c5cd --- /dev/null +++ b/compare-image-size.sh | |||
@@ -0,0 +1,21 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | |||
4 | declare -a IMAGES=( 'ansible/ubuntu14.04-ansible:stable' 'ansible/centos7-ansible:stable' \ | ||
5 | "williamyeh/ansible:debian8-onbuild" \ | ||
6 | "williamyeh/ansible:debian7-onbuild" \ | ||
7 | "williamyeh/ansible:ubuntu14.04-onbuild" \ | ||
8 | "williamyeh/ansible:ubuntu12.04-onbuild" \ | ||
9 | "williamyeh/ansible:centos7-onbuild" \ | ||
10 | "williamyeh/ansible:centos6-onbuild" | ||
11 | ) | ||
12 | |||
13 | for image in "${IMAGES[@]}" ; do | ||
14 | |||
15 | echo $image | ||
16 | docker pull $image | ||
17 | |||
18 | done | ||
19 | |||
20 | |||
21 | docker images | sort \ No newline at end of file | ||