Align salt version & repos
[fuel.git] / mcp / config / states / maas
index db0bd3f..67ef6d5 100755 (executable)
@@ -17,8 +17,11 @@ function wait_for() {
 # Wait for MaaS commissioning/deploy to finish, retry on failure
 function maas_fixup() {
   local statuscmd="salt 'mas01*' --out yaml state.apply maas.machines.status"
+  # shellcheck disable=SC2155
+  local ncount=$(salt --out yaml 'mas01*' pillar.get maas:region:machines | \
+    grep -cE '^\s{2}\w+:$')
   wait_for 180 "${statuscmd} | tee /dev/stderr | " \
-           "grep -Eq '((Deployed|Ready): 5|status:Failed|status:Allocated)'"
+    "grep -Eq '((Deployed|Ready): ${ncount}|status:Failed|status:Allocated)'"
   # shellcheck disable=SC2155
   local statusout=$(eval "${statuscmd}")
 
@@ -28,6 +31,7 @@ function maas_fixup() {
   for node_system_id in ${fcnodes}; do
     salt -C 'mas01*' state.apply maas.machines.delete \
       pillar="{'system_id': '${node_system_id}'}"
+    sleep 30
   done
   if [ -n "${fcnodes}" ]; then
     salt -C 'mas01*' state.apply maas.machines
@@ -40,6 +44,7 @@ function maas_fixup() {
   for node_system_id in ${fdnodes}; do
     salt -C 'mas01*' state.apply maas.machines.mark_broken_fixed \
       pillar="{'system_id': '${node_system_id}'}"
+    sleep 30
   done
   if [ -n "${fdnodes}" ]; then
     salt -C 'mas01*' state.apply maas.machines.deploy
@@ -56,8 +61,7 @@ salt -C 'mas01*' state.apply linux,salt,openssh,ntp
 salt -C 'mas01*' state.apply linux.network.interface
 salt -C 'mas01*' state.apply maas.pxe_nat
 salt -C 'mas01*' state.apply maas.cluster
-salt -C 'cfg01*' cmd.run \
-  "route add -net 192.168.11.0/24 gw ${MAAS_IP:-192.168.10.3}"
+salt -C 'cfg01*' state.apply maas.pxe_route
 
 wait_for 10 "salt -C 'mas01*' state.apply maas.region"
 
@@ -90,7 +94,8 @@ salt -C 'kvm*' state.sls libvirt
 
 salt -C '* and not cfg01* and not mas01*' state.apply salt
 salt -C 'kvm*' saltutil.sync_all
-salt -C 'kvm*' state.sls salt.control
+wait_for 10 "! salt -C 'kvm*' state.sls salt.control | " \
+  "tee /dev/stderr | fgrep -q 'Not connected'"
 
 vcp_nodes=$(salt --out yaml 'kvm01*' pillar.get salt:control:cluster:internal:node | \
             awk '/\s+\w+:$/ {gsub(/:$/, "*"); print $1}')