summaryrefslogtreecommitdiffstats
path: root/prototypes/openstack-ansible/scripts
diff options
context:
space:
mode:
authorwutianwei <wutianwei1@huawei.com>2017-02-07 16:35:27 +0800
committerYolanda Robla <yroblamo@redhat.com>2017-03-08 16:11:16 +0100
commit03829fdb10144e2afa29f9370a6ee4d18400e4b5 (patch)
tree99e9d076b5d67797406cbcd125f3020e3ba5410e /prototypes/openstack-ansible/scripts
parente1422b208fbd0455d56da0a50e6cdacf734dab96 (diff)
Add scripts and playbook to deploy OSA
The script and playbooks defined on this repo will deploy an OpenStack cloud based on OpenStack-Ansible. You just need to run the osa_deploy.sh. More information please refer to the README.md Change-Id: I731c366ab7197aefd7726150477ba1cc4d2932d3 Signed-off-by: wutianwei <wutianwei1@huawei.com>
Diffstat (limited to 'prototypes/openstack-ansible/scripts')
-rwxr-xr-xprototypes/openstack-ansible/scripts/osa_deploy.sh82
1 files changed, 82 insertions, 0 deletions
diff --git a/prototypes/openstack-ansible/scripts/osa_deploy.sh b/prototypes/openstack-ansible/scripts/osa_deploy.sh
new file mode 100755
index 000000000..95f593194
--- /dev/null
+++ b/prototypes/openstack-ansible/scripts/osa_deploy.sh
@@ -0,0 +1,82 @@
+#!/bin/bash
+
+export OSA_PATH=/opt/openstack-ansible
+export LOG_PATH=$OSA_PATH/log
+export PLAYBOOK_PATH=$OSA_PATH/playbooks
+export OSA_BRANCH=${OSA_BRANCH:-"master"}
+
+JUMPHOST_IP="192.168.122.2"
+
+sudo /bin/rm -rf $LOG_PATH
+sudo /bin/mkdir -p $LOG_PATH
+sudo /bin/cp /root/.ssh/id_rsa.pub ../file/authorized_keys
+sudo echo -e '\n'>>../file/authorized_keys
+
+cd ../playbooks/
+# this will prepare the jump host
+# git clone the Openstack-Ansible, bootstrap and configure network
+sudo ansible-playbook -i inventory jumphost_configuration.yml -vvv
+
+# this will prepare the target host
+# such as configure network and NFS
+sudo ansible-playbook -i inventory targethost_configuration.yml
+
+# using OpenStack-Ansible deploy the OpenStack
+
+echo "set UP Host !"
+sudo /bin/sh -c "ssh root@$JUMPHOST_IP openstack-ansible \
+ $PLAYBOOK_PATH/setup-hosts.yml" | \
+ tee $LOG_PATH/setup-host.log
+
+#check the result of openstack-ansible setup-hosts.yml
+#if failed, exit with exit code 1
+grep "failed=1" $LOG_PATH/setup-host.log>/dev/null \
+ || grep "unreachable=1" $LOG_PATH/setup-host.log>/dev/null
+if [ $? -eq 0 ]; then
+ echo "failed setup host!"
+ exit 1
+else
+ echo "setup host successfully!"
+fi
+
+echo "Set UP Infrastructure !"
+sudo /bin/sh -c "ssh root@$JUMPHOST_IP openstack-ansible \
+ $PLAYBOOK_PATH/setup-infrastructure.yml" | \
+ tee $LOG_PATH/setup-infrastructure.log
+
+grep "failed=1" $LOG_PATH/setup-infrastructure.log>/dev/null \
+ || grep "unreachable=1" $LOG_PATH/setup-infrastructure.log>/dev/null
+if [ $? -eq 0 ]; then
+ echo "failed setup infrastructure!"
+ exit 1
+else
+ echo "setup infrastructure successfully!"
+fi
+
+sudo /bin/sh -c "ssh root@$JUMPHOST_IP ansible -i $PLAYBOOK_PATH/inventory/ \
+ galera_container -m shell \
+ -a "mysql -h localhost -e 'show status like \"%wsrep_cluster_%\";'"" \
+ | tee $LOG_PATH/galera.log
+
+grep "FAILED" $LOG_PATH/galera.log>/dev/null
+if [ $? -eq 0 ]; then
+ echo "failed verify the database cluster!"
+ exit 1
+else
+ echo "verify the database cluster successfully!"
+fi
+
+echo "Set UP OpenStack !"
+sudo /bin/sh -c "ssh root@$JUMPHOST_IP openstack-ansible \
+ $PLAYBOOK_PATH/setup-openstack.yml" | \
+ tee $LOG_PATH/setup-openstack.log
+
+grep "failed=1" $LOG_PATH/setup-openstack.log>/dev/null \
+ || grep "unreachable=1" $LOG_PATH/setup-openstack.log>/dev/null
+if [ $? -eq 0 ]; then
+ echo "failed setup openstack!"
+ exit 1
+else
+ echo "OpenStack successfully deployed!"
+ exit 0
+fi