forked from jtreminio/docker-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init
executable file
·39 lines (32 loc) · 1.07 KB
/
init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env bash
set -e
set -o pipefail
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
CMD=${@:-ansible-playbook-wrapper}
source "${DIR}/.env"
SERVER_IP=${SERVER_IP:-}
#HOST_DNS=${HOST_DNS}
SSH_USER=${SSH_USER}
SSH_PRIVATE_KEY=${SSH_PRIVATE_KEY}
LE_EMAIL=${LE_EMAIL}
PORTAINER_ADMIN_PASS=${PORTAINER_ADMIN_PASS}
#PORTAINER_DASHBOARD_PATH=${PORTAINER_DASHBOARD_PATH}
if [[ -z "${SERVER_IP}" ]]; then
printf "You must create a .env file and define "
printf "SERVER_IP\n"
exit 1
fi
docker container run -it --rm \
-e INVENTORY=/etc/ansible/hosts.yml \
-e PLAYBOOK=/etc/ansible/playbook.yml \
-e ANSIBLE_HOST_KEY_CHECKING=false \
-e SERVER_IP=${SERVER_IP} \
-e SSH_USER=${SSH_USER} \
-e LE_EMAIL=${LE_EMAIL} \
-e PORTAINER_ADMIN_PASS=${PORTAINER_ADMIN_PASS} \
-v ${PWD}:/etc/ansible \
-v ${SSH_PRIVATE_KEY}:/root/.ssh/id_rsa \
williamyeh/ansible:ubuntu16.04-onbuild bash -c "${CMD}"
# -e HOST_DNS=${HOST_DNS} \
# -e PORTAINER_ADMIN_PASS=${PORTAINER_ADMIN_PASS} \
# -e PORTAINER_DASHBOARD_PATH=${PORTAINER_DASHBOARD_PATH} \