20610: Adds node list & role->nodes map variables.
[arvados.git] / tools / salt-install / local.params.example.multiple_hosts
index d1aab048c1ac0de6ff69faf65acfc287b3cd1bc0..c16b9cc27ba4b61045f69f11da73e308b5365034 100644 (file)
@@ -102,6 +102,35 @@ NODES=(
   [shell.${DOMAIN}]=shell
 )
 
+# Comma-separated list of nodes. This is used to dynamically adjust
+# salt pillars.
+NODELIST=""
+for node in "${!NODES[@]}"; do
+  if [ -z "$NODELIST" ]; then
+    NODELIST="$node"
+  else
+    NODELIST="$NODELIST,$node"
+  fi
+done
+
+# The mapping of roles to nodes. This is used to dinamically adjust
+# salt pillars.
+declare -A ROLES
+for node in "${!NODES[@]}"; do
+  roles="${NODES[$node]}"
+
+  # Split the comma-separated roles into an array
+  IFS=',' read -ra roles_array <<< "$roles"
+
+  for role in "${roles_array[@]}"; do
+    if [ -n "${ROLES[$role]:-}" ]; then
+      ROLES["$role"]="${ROLES[$role]},$node"
+    else
+      ROLES["$role"]=$node
+    fi
+  done
+done
+
 # Host SSL port where you want to point your browser to access Arvados
 # Defaults to 443 for regular runs, and to 8443 when called in Vagrant.
 # You can point it to another port if desired