Add new jobs for blueprint-pae repo
[ci-management.git] / jjb / shell / kni_deploy_aws.sh
index ce8eec5..d9c468d 100755 (executable)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-export PATH=$PATH:/usr/local/go/bin
-KNI_PATH='go/src/gerrit.akraino.org/kni/'
-
 set -e -u -x -o pipefail
 
+export PATH=$PATH:/usr/local/go/bin:/usr/local/bin
+KNI_PATH='src/gerrit.akraino.org/kni/'
+SITE_NAME='edge-sites-testing.devcluster.openshift.com'
+
 echo '---> Starting kni installer generation'
+export GOPATH=${WORKSPACE}/
 
-mkdir -p $HOME/${KNI_PATH}/installer
-export GOPATH=$HOME/go
+# move the blueprint to an inner directory
+mkdir ${WORKSPACE}/blueprint-pae
+mv base profiles sites tools ${WORKSPACE}/blueprint-pae/
 
-# move clone to gopath
-cp -R ${WORKSPACE}/* $HOME/${KNI_PATH}/installer/
+# clone installer in the right directory
+sudo rm -rf ${WORKSPACE}/${KNI_PATH}
+mkdir -p ${WORKSPACE}/${KNI_PATH}
+pushd ${WORKSPACE}/${KNI_PATH}/
+git clone https://gerrit.akraino.org/r/kni/installer
+pushd installer
 
 # first build kni installer
-pushd $HOME/${KNI_PATH}/installer
 make build 2>&1 | tee ${WORKSPACE}/build.log
 
-# then start aws deploy
-export CREDENTIALS=file://$(pwd)/akraino-secrets
-export BASE_REPO="git::https://gerrit.akraino.org/r/kni/templates"
-export BASE_PATH="aws/3-node"
-export SITE_REPO="git::https://gerrit.akraino.org/r/kni/templates"
-export SETTINGS_PATH="aws/sample_settings.yaml"
-make deploy 2>&1 | tee ${WORKSPACE}/aws_deploy.log
+# add the right credentials to kni
+mkdir $HOME/.kni || true
+cp $WORKSPACE/akraino-secrets/coreos-pull-secret $HOME/.kni/pull-secret.json || true
+
+# start the workflow
+./knictl fetch_requirements file://${WORKSPACE}/blueprint-pae//sites/${SITE_NAME} 2>&1 | tee ${WORKSPACE}/aws_requirements.log
+./knictl prepare_manifests ${SITE_NAME} 2>&1 | tee ${WORKSPACE}/aws_manifests.log
+
+# now run the cluster
+source $HOME/.kni/${SITE_NAME}/profile.env
+$HOME/.kni/${SITE_NAME}/requirements/openshift-install create cluster --dir=/$HOME/.kni/${SITE_NAME}/final_manifests 2>&1 | tee ${WORKSPACE}/aws_deploy.log
 STATUS=$?
 
 # output tfstate
 echo "metadata.json for removing cluster"
-cat $(pwd)/build/metadata.json
+cat $HOME/.kni/${SITE_NAME}/final_manifests/metadata.json
 
 if [ $STATUS -ne 0 ]; then
     echo "Error deploying in AWS"
     exit 1
 fi
 
-echo "Cluster successfully deployed! Starting cleanup"
-make clean
+echo "Cluster successfully deployed! Start applying workloads"
+./knictl apply_workloads ${SITE_NAME} 2>&1 | tee ${WORKSPACE}/aws_workloads.go
+STATUS=$?
+
+if [ $STATUS -ne 0 ]; then
+    echo "Error applying workloads to AWS"
+    exit 1
+fi
+
+echo "Workloads successfully applied! Starting cleanup"
+$HOME/.kni/${SITE_NAME}/requirements/openshift-install destroy cluster --dir=/$HOME/.kni/${SITE_NAME}/final_manifests 2>&1 | tee ${WORKSPACE}/aws_destroy.log
 STATUS=$?
 
 popd