Merge "states: Break on error, retry states up to 5 times" into stable/euphrates
[fuel.git] / mcp / config / states / openstack_ha
index 78da80a..2e55fc8 100755 (executable)
@@ -1,5 +1,16 @@
-#!/bin/bash
-set -x
+#!/bin/bash -e
+##############################################################################
+# Copyright (c) 2017 Mirantis Inc., Enea AB and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+CI_DEBUG=${CI_DEBUG:-0}; [[ "${CI_DEBUG}" =~ (false|0) ]] || set -x
+
+# shellcheck disable=SC1090
+source "$(dirname "${BASH_SOURCE[0]}")/../../scripts/lib.sh"
 
 salt -I 'keepalived:cluster' state.sls keepalived -b 1
 salt -I 'keepalived:cluster' pillar.get keepalived:cluster:instance:VIP:address
@@ -28,7 +39,6 @@ salt -I 'keystone:client' state.sls keystone.client
 salt -I 'keystone:server' cmd.run ". /root/keystonercv3; openstack service list"
 
 salt -I 'glance:server' state.sls glance -b 1
-salt -I 'glusterfs:client' state.sls glusterfs.client
 salt -I 'keystone:server' state.sls keystone.server
 
 salt -I 'nova:controller' state.sls nova -b 1
@@ -41,9 +51,10 @@ salt -I 'neutron:server' state.sls neutron -b 1
 salt -I 'neutron:gateway' state.sls neutron.gateway
 
 salt -I 'nova:compute' state.sls nova
+salt -I 'glusterfs:client' state.sls glusterfs.client
 
 salt -I 'mongodb:server' state.sls mongodb
-while true; do sleep 5; salt -C 'I@mongodb:server and *01*' cmd.run 'mongo localhost:27017/admin' && break; done
+wait_for 90 "salt -C 'I@mongodb:server and *01*' cmd.run 'mongo localhost:27017/admin'"
 salt -C 'I@mongodb:server and *01*' cmd.run 'mongo localhost:27017/admin --eval "rs.initiate()"'
 salt -C 'I@mongodb:server and *01*' state.sls mongodb
 
@@ -57,5 +68,5 @@ salt -I 'nginx:server' state.sls nginx
 clstr_vip_addr=$(salt -C 'I@nginx:server and *01*' --out=yaml \
   pillar.get _param:cluster_vip_address | awk '{print $2; exit}')
 salt -C 'I@nginx:server and *01*' cp.push \
-  /etc/ssl/certs/${clstr_vip_addr}-with-chain.crt upload_path='certs/os_cacert'
-cd /etc/ssl/certs && ln -s /var/cache/salt/master/minions/prx01.*/files/certs/os_cacert
+  "/etc/ssl/certs/${clstr_vip_addr}-with-chain.crt" upload_path='certs/os_cacert'
+cd /etc/ssl/certs && ln -sf /var/cache/salt/master/minions/prx01.*/files/certs/os_cacert