4 local total_attempts=360
7 echo "[NOTE] Waiting for cmd to return success: ${cmdstr}"
8 while ((attempt <= total_attempts)); do
9 eval "${cmdstr}" && break || true
10 echo -n '.'; sleep "${sleep_time}"
15 # MaaS rack/region controller, node commissioning
16 salt -C 'mas01*' cmd.run "add-apt-repository ppa:maas/stable"
18 salt -C 'mas01*' state.apply linux,salt,openssh,ntp
19 salt -C 'mas01*' state.apply linux.network.interface
20 salt -C 'mas01*' state.apply maas.pxe_nat
21 salt -C 'mas01*' state.apply maas.cluster
22 salt -C 'cfg01*' cmd.run \
23 "route add -net 192.168.11.0/24 gw ${MAAS_IP:-192.168.10.3}"
25 wait_for "salt -C 'mas01*' state.apply maas.region"
27 salt -C 'mas01*' state.apply maas.machines
28 # TODO: relax cond, as this is not re-entrant (e.g. nodes already deployed)
29 wait_for "salt 'mas01*' --out yaml state.apply maas.machines.status | " \
30 "tee /dev/stderr | fgrep -q 'Ready: 5'"
32 # cleanup outdated salt keys
33 salt-key --out yaml | awk '!/^(minions|- cfg01|- mas01)/ {print $2}' | xargs -I{} salt-key -yd {}
35 # MaaS node deployment
36 salt -C 'mas01*' state.apply maas.machines.deploy
37 wait_for "salt 'mas01*' --out yaml state.apply maas.machines.status | " \
38 "tee /dev/stderr | fgrep -q 'Deployed: 5'"
40 salt -C 'mas01*' pillar.item\
41 maas:region:admin:username \
42 maas:region:admin:password
44 # KVM, compute node prereqs (libvirt first), VCP deployment
45 salt -C '* and not cfg01* and not mas01*' saltutil.sync_all
47 salt -C 'kvm*' pkg.install bridge-utils
48 salt -C 'kvm*' state.apply linux.network
49 salt -C 'kvm*' system.reboot
50 wait_for "! salt '*' test.ping | tee /dev/stderr | fgrep -q 'Not connected'"
52 salt -C '* and not cfg01* and not mas01*' state.apply linux,ntp
54 salt -C 'kvm*' state.sls libvirt
56 salt -C '* and not cfg01* and not mas01*' state.apply salt
57 salt -C 'kvm*' state.sls salt.control
59 vcp_nodes=$(salt --out yaml 'kvm01*' pillar.get salt:control:cluster:internal:node | awk '/\s+\w+:$/ {gsub(/:$/, "*"); print $1}')
61 # Check all vcp nodes are available
63 while [ $rc -ne 0 ]; do
65 for node in $vcp_nodes; do
66 salt "$node" test.ping 2>/dev/null 1>&2 || { rc=$?; break; };
70 salt -C '* and not cfg01* and not mas01*' saltutil.sync_all
71 salt -C '* and not cfg01* and not mas01*' state.apply salt
72 wait_for "salt -C '* and not cfg01* and not mas01*' state.apply linux,ntp"