2 # SPDX-license-identifier: Apache-2.0
3 ##############################################################################
4 # Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
14 export OSA_PATH=/opt/openstack-ansible
15 export LOG_PATH=$OSA_PATH/log
16 export PLAYBOOK_PATH=$OSA_PATH/playbooks
17 export OSA_BRANCH=${OSA_BRANCH:-"master"}
18 XCIMASTER_IP="192.168.122.2"
20 sudo /bin/rm -rf $LOG_PATH
21 sudo /bin/mkdir -p $LOG_PATH
22 sudo /bin/cp /root/.ssh/id_rsa.pub ../file/authorized_keys
23 echo -e '\n' | sudo tee --append ../file/authorized_keys
27 echo "***********************************************************************"
29 echo "* Configure XCI Master *"
31 echo "* Bootstrap xci-master, configure network, clone openstack-ansible *"
32 echo "* Playbooks: configure-xcimaster.yml *"
34 echo "***********************************************************************"
38 # this will prepare the jump host
39 # git clone the Openstack-Ansible, bootstrap and configure network
40 echo "xci: running ansible playbook configure-xcimaster.yml"
41 sudo -E ansible-playbook -i inventory configure-xcimaster.yml
43 echo "XCI Master is configured successfully!"
47 echo "***********************************************************************"
49 echo "* Configure Nodes *"
51 echo "* Configure network on OpenStack Nodes, configure NFS *"
52 echo "* Playbooks: configure-targethosts.yml *"
54 echo "***********************************************************************"
57 # this will prepare the target host
58 # such as configure network and NFS
59 echo "xci: running ansible playbook configure-targethosts.yml"
60 sudo -E ansible-playbook -i inventory configure-targethosts.yml
62 echo "Nodes are configured successfully!"
66 echo "***********************************************************************"
68 echo "* Set Up OpenStack Nodes *"
70 echo "* Set up OpenStack Nodes using openstack-ansible *"
71 echo "* Playbooks: setup-hosts.yml, setup-infrastructure.yml *"
73 echo "***********************************************************************"
76 # using OpenStack-Ansible deploy the OpenStack
77 echo "xci: running ansible playbook setup-hosts.yml"
78 sudo -E /bin/sh -c "ssh root@$XCIMASTER_IP openstack-ansible \
79 $PLAYBOOK_PATH/setup-hosts.yml" | \
80 tee $LOG_PATH/setup-hosts.log
82 # check the result of openstack-ansible setup-hosts.yml
83 # if failed, exit with exit code 1
84 if grep -q 'failed=1\|unreachable=1' $LOG_PATH/setup-hosts.log; then
85 echo "OpenStack node setup failed!"
89 echo "xci: running ansible playbook setup-infrastructure.yml"
90 sudo -E /bin/sh -c "ssh root@$XCIMASTER_IP openstack-ansible \
91 $PLAYBOOK_PATH/setup-infrastructure.yml" | \
92 tee $LOG_PATH/setup-infrastructure.log
94 # check the result of openstack-ansible setup-infrastructure.yml
95 # if failed, exit with exit code 1
96 if grep -q 'failed=1\|unreachable=1' $LOG_PATH/setup-infrastructure.log; then
97 echo "OpenStack node setup failed!"
101 echo "OpenStack nodes are setup successfully!"
103 sudo -E /bin/sh -c "ssh root@$XCIMASTER_IP ansible -i $PLAYBOOK_PATH/inventory/ \
104 galera_container -m shell \
105 -a "mysql -h localhost -e 'show status like \"%wsrep_cluster_%\";'"" \
106 | tee $LOG_PATH/galera.log
108 if grep -q 'FAILED' $LOG_PATH/galera.log; then
109 echo "Database cluster verification failed!"
112 echo "Database cluster verification successful!"
117 echo "***********************************************************************"
119 echo "* Install OpenStack *"
120 echo "* Playbooks: opnfv-setup-openstack.yml *"
122 echo "***********************************************************************"
125 echo "xci: running ansible playbook opnfv-setup-openstack.yml"
126 sudo -E /bin/sh -c "ssh root@$XCIMASTER_IP openstack-ansible \
127 $PLAYBOOK_PATH/opnfv-setup-openstack.yml" | \
128 tee $LOG_PATH/opnfv-setup-openstack.log
130 if grep -q 'failed=1\|unreachable=1' $LOG_PATH/opnfv-setup-openstack.log; then
131 echo "OpenStack installation failed!"
134 echo "OpenStack installation is successfully completed!"