-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdocker-entrypoint.sh
executable file
·103 lines (91 loc) · 3.15 KB
/
docker-entrypoint.sh
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/sh
set -e
ANSIBLE_ROOT="/examples"
ANSIBLE_INVENTORY="${ANSIBLE_ROOT}/inventory"
ANSIBLE_SERVER_GROUP="clusternodes"
if [ "$1" = 'get-tarball' ]; then
echo "=> Copy collection tarball outside of container"
cd /opt && cp -f *.tar.gz ${ANSIBLE_ROOT}/
exit $?
fi
if [ "$1" = 'run' ]; then
echo "=> Provision a new cluster"
ansible-playbook -i ${ANSIBLE_INVENTORY} playbook-provision-cluster.yml --limit ${ANSIBLE_SERVER_GROUP}
exit $?
fi
if [ "$1" = 'unprovision-cluster' ]; then
echo "=> Unprovision services and cluster"
read -p "Are you sure? " -n 1 -r
echo
ret=0
if [[ $REPLY == 'y' ]]
then
ansible-playbook -i ${ANSIBLE_INVENTORY} playbook-unprovision-cluster.yml --limit ${ANSIBLE_SERVER_GROUP}
fi
exit $ret
fi
if [ "$1" = 'unprovision-services' ]; then
echo "=> Unprovision services"
read -p "Are you sure? " -n 1 -r
echo
ret=0
if [[ $REPLY == 'y' ]]
then
ansible-playbook -i ${ANSIBLE_INVENTORY} playbook-unprovision-services.yml --limit ${ANSIBLE_SERVER_GROUP}
fi
exit $ret
fi
if [ "$1" = 'check-playbooks' ]; then
for playbook in $(cd ${ANSIBLE_ROOT} && ls -1 *.yml)
do
echo
echo "=> Start syntax checking & linting for playbook $playbook"
ansible-playbook -i ${ANSIBLE_INVENTORY} --syntax-check ${ANSIBLE_ROOT}/$playbook --limit ${ANSIBLE_SERVER_GROUP}
ansible-lint -v ${ANSIBLE_ROOT}/$playbook
echo "=> End of syntax checking & linting for playbook $playbook"
done
exit $?
fi
if [ "$1" = 'ansible-lint-cluster-roles' ]; then
for role in $(cd /usr/share/ansible/collections/ansible_collections/opensvc/cluster/roles && ls -1)
do
echo "=> Start syntax linting for cluster role $role"
ansible-lint /usr/share/ansible/collections/ansible_collections/opensvc/cluster/roles/$role
echo "=> End of syntax linting for cluster role $role"
echo
done
exit $?
fi
if [ "$1" = 'ansible-lint-app-roles' ]; then
for role in $(cd /usr/share/ansible/collections/ansible_collections/opensvc/app/roles && ls -1)
do
echo "=> Start syntax linting for app role $role"
ansible-lint /usr/share/ansible/collections/ansible_collections/opensvc/app/roles/$role
echo "=> End of syntax linting for app role $role"
echo
done
exit $?
fi
if [ "$1" = 'ansible-lint-collections' ]; then
for collection in $(cd /usr/share/ansible/collections/ansible_collections/opensvc && ls -1)
do
echo "=> Start syntax linting for collection $collection"
cd /usr/share/ansible/collections/ansible_collections/opensvc/$collection
ansible-lint
echo "=> End of syntax linting for role $collection"
echo
done
exit $?
fi
if [ "$1" = 'ansible-test-sanity' ]; then
for collection in $(cd /usr/share/ansible/collections/ansible_collections/opensvc && ls -1)
do
echo "=> Start ansible-test for collection opensvc/$collection"
cd /usr/share/ansible/collections/ansible_collections/opensvc/$collection
ansible-test sanity
echo "=> End of ansible-test for collection opensvc/$collection"
echo
done
exit $?
fi
exec "$@"