blob: 2c3211fab18a71938dd177a245d4a0f1171ece74 [file] [log] [blame]
Mikhail Ivanov614feb52017-11-09 16:10:46 +04001#!/bin/bash -x
2exec > >(tee -i /tmp/"$(basename "$0" .sh)"_"$(date '+%Y-%m-%d_%H-%M-%S')".log) 2>&1
3
4install_infra () {
5 # DOP config and rundeck files should be created before container start
6 salt -C 'I@devops_portal:config' state.sls devops_portal.config
7 salt -C 'I@rundeck:server' state.sls rundeck.server
8}
9
10install_services () {
11 # Up containers
12 salt -C 'I@docker:swarm:role:master' state.sls docker.client
13
14 # XXX: first run may fails
15 salt -C 'I@postgresql:client' cmd.run 'while true; do if docker service logs postgresql_db | grep "ready to accept"; then break; else sleep 5; fi; done'
16 for i in $(seq 2); do
17 salt -C 'I@postgresql:client' state.sls postgresql.client
18 sleep 10
19 done
20
21 # Rundeck client, jobs, and etc
22 salt -C 'I@rundeck:client' cmd.run 'while true; do curl -sf 172.16.10.254:4440 >/dev/null && break; done'
23 salt -C 'I@rundeck:client' state.sls rundeck.client
24
25 # ElasticSearch indicies
26 salt -C 'I@elasticsearch:client' cmd.run 'while true; do curl -sf 172.16.10.254:9200 >/dev/null && break; done'
27 for i in $(seq 3); do
28 salt -C 'I@elasticsearch:client' state.sls elasticsearch.client
29 sleep 10
30 done
31}
32
33case "$1" in
34 "infra")
35 install_infra
36 ;;
37 "services")
38 install_services
39 ;;
40esac