Add bash scripts for oss bootstrapping

Closes-US: PROD-15430

Change-Id: I27fea09181c7efbdf502e1c38c51e39abdbe53b9
diff --git a/scripts/bootstrap_all.sh b/scripts/bootstrap_all.sh
index 445464e..2219d00 100755
--- a/scripts/bootstrap_all.sh
+++ b/scripts/bootstrap_all.sh
@@ -5,12 +5,16 @@
 K8S_BOOTSTRAP=$(salt -C 'I@kubernetes:master' test.ping 1>/dev/null 2>&1 && echo true)
 OPENSTACK_BOOTSTRAP=$(salt -C 'I@nova:controller' test.ping 1>/dev/null 2>&1 && echo true)
 OPENCONTRAIL_BOOTSTRAP=$(salt -C 'I@opencontrail:control' test.ping 1>/dev/null 2>&1 && echo true)
+OSS_BOOTSTRAP=$(salt -C 'I@devops_portal:config' test.ping 1>/dev/null 2>&1 && echo true)
 STACKLIGHTV2_BOOTSTRAP=$(salt -C 'I@prometheus:server' test.ping 1>/dev/null 2>&1 && echo true)
 
 "$CWD"/config_verify.sh
 "$CWD"/infra_install.sh
 "$CWD"/core_services_install.sh
-if [[ "$STACKLIGHTV2_BOOTSTRAP" == "true" ]]; then
+if [[ "$OSS_BOOTSTRAP" == "true" ]]; then
+    "$CWD"/oss_install.sh infra
+fi
+if [[ "$STACKLIGHTV2_BOOTSTRAP" == "true" ]] || [[ "$OSS_BOOTSTRAP" == "true" ]]; then
     "$CWD"/docker_swarm_install.sh
 fi
 if [[ "$K8S_BOOTSTRAP" == "true" ]]; then
@@ -30,3 +34,6 @@
 if [[ "$STACKLIGHTV2_BOOTSTRAP" == "true" ]]; then
     "$CWD"/stacklightv2_infra_install.sh
 fi
+if [[ "$OSS_BOOTSTRAP" == "true" ]]; then
+    "$CWD"/oss_install.sh services
+fi
diff --git a/scripts/oss_install.sh b/scripts/oss_install.sh
new file mode 100755
index 0000000..2c3211f
--- /dev/null
+++ b/scripts/oss_install.sh
@@ -0,0 +1,40 @@
+#!/bin/bash -x
+exec > >(tee -i /tmp/"$(basename "$0" .sh)"_"$(date '+%Y-%m-%d_%H-%M-%S')".log) 2>&1
+
+install_infra () {
+  # DOP config and rundeck files should be created before container start
+  salt -C 'I@devops_portal:config' state.sls devops_portal.config
+  salt -C 'I@rundeck:server' state.sls rundeck.server
+}
+
+install_services () {
+  # Up containers
+  salt -C 'I@docker:swarm:role:master' state.sls docker.client
+
+  # XXX: first run may fails
+  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'
+  for i in $(seq 2); do
+      salt -C 'I@postgresql:client' state.sls postgresql.client
+      sleep 10
+  done
+
+  # Rundeck client, jobs, and etc
+  salt -C 'I@rundeck:client' cmd.run 'while true; do curl -sf 172.16.10.254:4440 >/dev/null && break; done'
+  salt -C 'I@rundeck:client' state.sls rundeck.client
+
+  # ElasticSearch indicies
+  salt -C 'I@elasticsearch:client' cmd.run 'while true; do curl -sf 172.16.10.254:9200 >/dev/null && break; done'
+  for i in $(seq 3); do
+    salt -C 'I@elasticsearch:client' state.sls elasticsearch.client
+    sleep 10
+  done
+}
+
+case "$1" in
+  "infra")
+    install_infra
+  ;;
+  "services")
+    install_services
+  ;;
+esac