Mikhail Ivanov | 614feb5 | 2017-11-09 16:10:46 +0400 | [diff] [blame^] | 1 | #!/bin/bash -x |
| 2 | exec > >(tee -i /tmp/"$(basename "$0" .sh)"_"$(date '+%Y-%m-%d_%H-%M-%S')".log) 2>&1 |
| 3 | |
| 4 | install_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 | |
| 10 | install_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 | |
| 33 | case "$1" in |
| 34 | "infra") |
| 35 | install_infra |
| 36 | ;; |
| 37 | "services") |
| 38 | install_services |
| 39 | ;; |
| 40 | esac |