5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 COMMAND=$(basename "${0}")
18 DO_REBOOT_IF_NEEDED=true
21 # Source log variables and functions
23 source $(dirname "${BASH_SOURCE[0]}")/log.sh
25 function source_common()
28 SCRIPT_PATH=$(dirname "${BASH_SOURCE[0]}")
29 local COMMON_SH_FILE=${SCRIPT_PATH}/common.sh
30 # shellcheck disable=SC1091
32 source "${COMMON_SH_FILE}" && return 0
33 log_error "Failed to source ${COMMON_SH_FILE}"
37 export CONFIG_PHASE="bootstrapping"
41 log_info "Bootstrapping started"
43 declare -a FUNCTIONS=(source_common start_db start_cm start_installation)
45 for func in "${FUNCTIONS[@]}"
55 wait_installation_complete
58 if [ $rc -eq 0 ]; then
59 export CONFIG_PHASE="postconfig"
60 log_info "Generate inventory file to prepare for extra playbooks run"
61 run_cmd "$CMCLI ansible-inventory > $INVENTORY_FILE"
64 for d in $(ls -d /home/*); do
65 if [ -f "$d/openrc" ]; then
66 admin=$(basename "$d")
71 #take a copy of the initial configuration data
72 mkdir /root/.initconfig
73 cp /var/lib/redis/dump.rdb /root/.initconfig/
75 su - "$admin" -c "/usr/local/bin/openstack-ansible -b -u $admin /opt/openstack-ansible/playbooks/finalize-playbook.yml" &>> $BOOTSTRAP_LOG
78 if [ $rc -eq 0 ]; then
87 log_info "starting redis again"
90 if [ $rc -eq 0 ]; then
91 if has_kernel_parameters_changed;
93 # The status of the installation will be logged by one of the following services after the host is rebooted.
95 # 1) finalize-bootstrap.service: When the performance porfile is enabled on the controller-1 and
96 # the network type is "ovs"
97 # 2) enable-dpdk.service: When the performance profile is enabled on the controller-1 and the
98 # network type is "ovs-dpdk"
100 if [ ${DO_REBOOT_IF_NEEDED} == true ]; then
103 log_info "Rebooting of host is skipped as requested."
106 log_installation_success
107 /opt/openstack-ansible/playbooks/report-installation-progress --status completed --description "Installation complete" --percentage 100
110 log_installation_failure
111 /opt/openstack-ansible/playbooks/report-installation-progress --status failed --description "Installation failed"
120 echo "# ${COMMAND} <full path to user-config-yaml|restore-config-yaml>"
121 echo "Or to skip the controller-1 reboot in the case kernel boot parameters are changed"
122 echo "# ${COMMAND} <full path to user-config-yaml|restore-config-yaml> (--install | --restore) --no-reboot"
126 # Assume that the first argument is the configuration file to maintain backwards compatibility
127 # so handle it separately.
130 if [ $# -lt 1 ]; then
138 if ! [ -f "${CONFIG_FILE}" ]; then
139 log_error "Failed to open file:${CONFIG_FILE}"
146 # And then the remaing arguments in any order
149 IS_INSTALL_ARG_SPECIFIED=false
154 DO_REBOOT_IF_NEEDED=false
158 IS_INSTALL_ARG_SPECIFIED=true
166 log_error "Unknown option: ${arg}"
173 log_info "====================================================================="
174 log_info "Boot strapping the environment with $CONFIG_FILE"
175 log_info "====================================================================="