blob: 923b59aaca8cdf84a8405127a9ffe3c8abb76703 (
plain)
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
|
#!/bin/bash
# find other running nodes
other_nodes_found=1
for i in $(echo "{% raw %}{{ openbook_gcomm_addresses }}{% endraw %}" | sed -e 's|,| |g'); do
if [ "${i}" != "{% raw %}{{ ansible_default_ipv4.address }}{% endraw %}" ]; then
nc ${i} 4567 </dev/null >/dev/null
if [ "${?}" == "0" ]; then
other_nodes_found=0
fi
fi
done
# bootstrap or cluster join depending on whether other nodes were found
if [ "${other_nodes_found}" == "0" ]; then
mysql_args=""
else
mysql_args="--wsrep-new-cluster"
fi
docker run \
-d \
--rm \
--net=host \
-p 3306:3306 \
-p 4444:4444 \
-p 4567:4567 \
-p 4567:4567/udp \
-p 4568:4568 \
-p 9200:9200 \
-v {{ pillar["database"]["dirs"]["etc_openbook_database"]["name"] }}:/etc/mysql \
-v {{ pillar["database"]["dirs"]["var_lib_mysql"]["name"] }}:/var/lib/mysql \
-v {{ pillar["database"]["dirs"]["var_log_mysql"]["name"] }}:/var/log/mysql \
--name {{ pillar["database"]["container_name"] }} \
{{ pillar["registry"]["url"] }}/{{ pillar["database"]["image_name"] }} \
${mysql_args}
exit 0
|