summaryrefslogtreecommitdiffstats
path: root/openstack-ansible/scripts
diff options
context:
space:
mode:
authorwutianwei <wutianwei1@huawei.com>2017-02-07 16:35:27 +0800
committerTrevor Bramwell <tbramwell@linuxfoundation.org>2017-08-11 12:56:12 -0700
commit2d16c440ef7ef0aa8e807df33fa25783952b93d1 (patch)
tree1a86135e841d56d664246ea0d5a7bac5902c555c /openstack-ansible/scripts
parentf37b1727593632eae93a6347ccf628325e430d01 (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 'openstack-ansible/scripts')
-rwxr-xr-xopenstack-ansible/scripts/osa_deploy.sh82
1 files changed, 82 insertions, 0 deletions
diff --git a/openstack-ansible/scripts/osa_deploy.sh b/openstack-ansible/scripts/osa_deploy.sh
new file mode 100755
index 00000000..95f59319
--- /dev/null
+++ b/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