diff options
author | William Yeh <william.pjyeh@gmail.com> | 2017-09-14 15:57:43 +0800 |
---|---|---|
committer | William Yeh <william.pjyeh@gmail.com> | 2017-09-14 17:56:59 +0800 |
commit | deeab1a101da6710574174dbe47199f9e8900b93 (patch) | |
tree | 95605a54ab972f9b821267be534103803fb84f2a /mini-debian9 | |
parent | 57d366d79328ee5d127d05644b108bd4f7915cdc (diff) | |
download | docker-ansible-deeab1a101da6710574174dbe47199f9e8900b93.tar.gz docker-ansible-deeab1a101da6710574174dbe47199f9e8900b93.tar.zst docker-ansible-deeab1a101da6710574174dbe47199f9e8900b93.zip |
Add: Debian 9 ("Stretch") support.
Diffstat (limited to 'mini-debian9')
-rw-r--r-- | mini-debian9/Dockerfile | 27 | ||||
-rwxr-xr-x | mini-debian9/ansible-playbook-wrapper | 49 | ||||
-rw-r--r-- | mini-debian9/apt-list | 21 | ||||
-rwxr-xr-x | mini-debian9/install-ansible.sh | 27 | ||||
-rwxr-xr-x | mini-debian9/prepare-pkg-list.sh | 37 | ||||
-rwxr-xr-x | mini-debian9/uninstall-ansible.sh | 21 |
6 files changed, 182 insertions, 0 deletions
diff --git a/mini-debian9/Dockerfile b/mini-debian9/Dockerfile new file mode 100644 index 0000000..8de9dd0 --- /dev/null +++ b/mini-debian9/Dockerfile | |||
@@ -0,0 +1,27 @@ | |||
1 | # Dockerfile for building Debian-based image, via Ansible playbooks. | ||
2 | # | ||
3 | # @see http://docs.ansible.com/ansible/intro_installation.html#running-from-source | ||
4 | # | ||
5 | # Version 1.0 | ||
6 | # | ||
7 | |||
8 | |||
9 | # pull base image | ||
10 | FROM debian:9 | ||
11 | |||
12 | MAINTAINER William Yeh <william.pjyeh@gmail.com> | ||
13 | |||
14 | #ENV APT_LIST apt-list | ||
15 | |||
16 | |||
17 | COPY . /tmp | ||
18 | |||
19 | ONBUILD COPY . /tmp | ||
20 | ONBUILD RUN \ | ||
21 | cd /tmp && \ | ||
22 | ./prepare-pkg-list.sh && \ | ||
23 | ./install-ansible.sh && \ | ||
24 | ./ansible-playbook-wrapper && \ | ||
25 | ./uninstall-ansible.sh && \ | ||
26 | cd / && \ | ||
27 | rm -rf /tmp/* \ No newline at end of file | ||
diff --git a/mini-debian9/ansible-playbook-wrapper b/mini-debian9/ansible-playbook-wrapper new file mode 100755 index 0000000..0ba45e6 --- /dev/null +++ b/mini-debian9/ansible-playbook-wrapper | |||
@@ -0,0 +1,49 @@ | |||
1 | #!/bin/sh | ||
2 | # | ||
3 | # Simple wrapper for executing ansible-galaxy and ansible-playbook | ||
4 | # with local connection. | ||
5 | # | ||
6 | # USAGE: | ||
7 | # ansible-playbook-wrapper [other ansible-playbook arguments] | ||
8 | # | ||
9 | # ENVIRONMENT VARIABLES: | ||
10 | # | ||
11 | # - REQUIREMENTS: requirements filename; default = "requirements.yml" | ||
12 | # - PLAYBOOK: playbook filename; default = "playbook.yml" | ||
13 | # - INVENTORY: inventory filename; default = "/etc/ansible/hosts" | ||
14 | # | ||
15 | |||
16 | |||
17 | # | ||
18 | # install Galaxy roles, if any | ||
19 | # | ||
20 | |||
21 | if [ -z "$REQUIREMENTS" ]; then | ||
22 | REQUIREMENTS=requirements.yml | ||
23 | fi | ||
24 | |||
25 | if [ -f "$REQUIREMENTS" ]; then | ||
26 | ansible-galaxy install -r $REQUIREMENTS | ||
27 | fi | ||
28 | |||
29 | |||
30 | # | ||
31 | # execute playbook | ||
32 | # | ||
33 | |||
34 | if [ -z "$PLAYBOOK" ]; then | ||
35 | PLAYBOOK=playbook.yml | ||
36 | fi | ||
37 | |||
38 | |||
39 | if [ -z "$INVENTORY" ]; then | ||
40 | exec ansible-playbook \ | ||
41 | $PLAYBOOK \ | ||
42 | --connection=local \ | ||
43 | "$@" | ||
44 | else | ||
45 | exec ansible-playbook \ | ||
46 | -i $INVENTORY $PLAYBOOK \ | ||
47 | --connection=local \ | ||
48 | "$@" | ||
49 | fi | ||
diff --git a/mini-debian9/apt-list b/mini-debian9/apt-list new file mode 100644 index 0000000..7f23377 --- /dev/null +++ b/mini-debian9/apt-list | |||
@@ -0,0 +1,21 @@ | |||
1 | # | ||
2 | # packages to be installed via APT; | ||
3 | # lines beginning with "! " (an exclamation mark, followed by a space) will *not* be *uninstalled* afterwards. | ||
4 | # | ||
5 | |||
6 | |||
7 | # common | ||
8 | #####sudo curl gcc | ||
9 | |||
10 | # ssl | ||
11 | #####openssl ca-certificates | ||
12 | |||
13 | # python-runtime | ||
14 | python | ||
15 | #####python-pip python-yaml | ||
16 | |||
17 | # build-dependencies | ||
18 | #####python-dev libffi-dev libssl-dev | ||
19 | |||
20 | # may be required by ansible-galaxy | ||
21 | git \ No newline at end of file | ||
diff --git a/mini-debian9/install-ansible.sh b/mini-debian9/install-ansible.sh new file mode 100755 index 0000000..6083050 --- /dev/null +++ b/mini-debian9/install-ansible.sh | |||
@@ -0,0 +1,27 @@ | |||
1 | #!/bin/sh | ||
2 | # | ||
3 | # Simple wrapper for installing ansible | ||
4 | # | ||
5 | |||
6 | |||
7 | export DEBIAN_FRONTEND=noninteractive | ||
8 | |||
9 | |||
10 | echo "===> Adding prerequisites..." | ||
11 | |||
12 | apt-get update -y | ||
13 | cat ___APT_INSTALL_LIST | \ | ||
14 | while read ITEM; do | ||
15 | apt-get install -y $ITEM | ||
16 | done | ||
17 | |||
18 | |||
19 | |||
20 | echo "===> Installing Ansible..." | ||
21 | apt-get install -y ansible | ||
22 | |||
23 | |||
24 | |||
25 | echo "===> Adding hosts for convenience..." && \ | ||
26 | mkdir -p /etc/ansible && \ | ||
27 | echo 'localhost' > /etc/ansible/hosts | ||
diff --git a/mini-debian9/prepare-pkg-list.sh b/mini-debian9/prepare-pkg-list.sh new file mode 100755 index 0000000..ce2195d --- /dev/null +++ b/mini-debian9/prepare-pkg-list.sh | |||
@@ -0,0 +1,37 @@ | |||
1 | #!/bin/sh | ||
2 | # | ||
3 | # Prepare the list of packages to be installed/uninstalled. | ||
4 | # | ||
5 | # ENVIRONMENT VARIABLES: | ||
6 | # | ||
7 | # - APT_LIST: APT package list; default = "apt-list" | ||
8 | # | ||
9 | |||
10 | echo "===> Preparing APT package list..." | ||
11 | |||
12 | if [ -z "$APT_LIST" ]; then | ||
13 | APT_LIST=apt-list | ||
14 | fi | ||
15 | |||
16 | if [ -f "$APT_LIST" ]; then | ||
17 | |||
18 | awk '/^#/ {next} \ | ||
19 | { split($0,arrayA); \ | ||
20 | for (i in arrayA) { \ | ||
21 | if (arrayA[i] == "!") { continue; } \ | ||
22 | print arrayA[i] \ | ||
23 | } \ | ||
24 | }' \ | ||
25 | $APT_LIST > ___APT_INSTALL_LIST | ||
26 | |||
27 | awk '/^(#|!)/ {next} \ | ||
28 | { split($0,arrayA); for (i in arrayA) print arrayA[i] }' \ | ||
29 | $APT_LIST | | ||
30 | awk '{ L[n++] = $0 } \ | ||
31 | END { while(n--) \ | ||
32 | print L[n] }' \ | ||
33 | > ___APT_UNINSTALL_LIST | ||
34 | |||
35 | fi | ||
36 | #cat ___APT_INSTALL_LIST | ||
37 | #cat ___APT_UNINSTALL_LIST | ||
diff --git a/mini-debian9/uninstall-ansible.sh b/mini-debian9/uninstall-ansible.sh new file mode 100755 index 0000000..3573413 --- /dev/null +++ b/mini-debian9/uninstall-ansible.sh | |||
@@ -0,0 +1,21 @@ | |||
1 | #!/bin/sh | ||
2 | # | ||
3 | # Simple wrapper for uninstall ansible and related stuff. | ||
4 | # | ||
5 | |||
6 | |||
7 | echo "===> Removing Ansible..." | ||
8 | apt-get -f -y --auto-remove remove ansible | ||
9 | |||
10 | echo "===> Removing APT packages..." | ||
11 | cat ___APT_UNINSTALL_LIST | \ | ||
12 | while read ITEM; do | ||
13 | apt-get -f -y --auto-remove remove $ITEM | ||
14 | done | ||
15 | apt-get clean | ||
16 | |||
17 | |||
18 | echo "===> Cleaning up package list..." | ||
19 | rm -rf /etc/python /etc/python2.7 | ||
20 | rm -rf /etc/ansible /root/.ansible /root/.cache | ||
21 | rm -rf /var/lib/apt/lists/* /etc/apt/sources.list.d /var/cache/* /var/log/* | ||