openstack-ansible-ops/leap-upgrades/upgrade.sh
Kevin Carter 2438ad03ab Added leap upgrade tooling
This change adds upgrade tooling that will take a Juno based
OpenStack-Ansible cloud and upgrade it to Newton. The tooling
will run a deployment through all of the needed steps upgrading
the environment and skipping all of the OpenStack releases in
between.

**This tooling should be considered experimental at this time**

Change-Id: I1880794717b9e47786ae255ea1afa57d805cde8e
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
2017-02-01 14:27:07 +00:00

134 lines
6.9 KiB
Bash
Executable File

#!/usr/bin/env bash
# Copyright 2017, Rackspace US, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# NOTICE: To run this in an automated fashion run the script via
# root@HOSTNAME:/opt/openstack-ansible# echo "YES" | bash scripts/run-upgrade.sh
## Shell Opts ----------------------------------------------------------------
set -e -u -v
## Main ----------------------------------------------------------------------
source lib/vars.sh
source lib/functions.sh
### Kilo System migration
# Run tasks
UPGRADE_SCRIPTS="${UPGRADE_UTILS}-kilo/scripts"
# If the kilo leap has been accomplished, skip.
if [[ ! -f "/opt/leap42/openstack-ansible-${KILO_RELEASE}.leap" ]]; then
notice 'Running kilo leap'
link_release "/opt/leap42/openstack-ansible-${KILO_RELEASE}"
pushd "/opt/leap42/openstack-ansible-${KILO_RELEASE}"
if [[ -d "/etc/rpc_deploy" ]]; then
SCRIPTS_PATH="/opt/leap42/openstack-ansible-${KILO_RELEASE}/scripts" MAIN_PATH="/opt/leap42/openstack-ansible-${KILO_RELEASE}" ${UPGRADE_SCRIPTS}/create-new-openstack-deploy-structure.sh
fi
${UPGRADE_SCRIPTS}/juno-rpc-extras-create.py
SCRIPTS_PATH="/opt/leap42/openstack-ansible-${KILO_RELEASE}/scripts" MAIN_PATH="/opt/leap42/openstack-ansible-${KILO_RELEASE}" ${UPGRADE_SCRIPTS}/new-variable-prep.sh
# Convert LDAP variables if any are found
if grep '^keystone_ldap.*' /etc/openstack_deploy/user_variables.yml;then
${UPGRADE_SCRIPTS}/juno-kilo-ldap-conversion.py
fi
# Create the repo servers entries from the same entries found within the infra_hosts group.
if ! grep -r '^repo-infra_hosts\:' /etc/openstack_deploy/openstack_user_config.yml /etc/openstack_deploy/conf.d/;then
if [ ! -f "/etc/openstack_deploy/conf.d/repo-servers.yml" ];then
${UPGRADE_SCRIPTS}/juno-kilo-add-repo-infra.py
fi
fi
# In Kilo+ we need to mark the network used for container ssh and management.
if ! grep -q "is_container_address" /etc/openstack_deploy/openstack_user_config.yml; then
sed -i.bak '/container_bridge: "br-mgmt"/a \ \ \ \ \ \ \ \ is_container_address: true' /etc/openstack_deploy/openstack_user_config.yml
fi
if ! grep -q "is_ssh_address" /etc/openstack_deploy/openstack_user_config.yml; then
sed -i.bak '/container_bridge: "br-mgmt"/a \ \ \ \ \ \ \ \ is_ssh_address: true' /etc/openstack_deploy/openstack_user_config.yml
fi
${UPGRADE_SCRIPTS}/juno-is-metal-preserve.py
SCRIPTS_PATH="/opt/leap42/openstack-ansible-${KILO_RELEASE}/scripts" MAIN_PATH="/opt/leap42/openstack-ansible-${KILO_RELEASE}" ${UPGRADE_SCRIPTS}/old-variable-remove.sh
SCRIPTS_PATH="/opt/leap42/openstack-ansible-${KILO_RELEASE}/scripts" MAIN_PATH="/opt/leap42/openstack-ansible-${KILO_RELEASE}" ${UPGRADE_SCRIPTS}/juno-container-cleanup.sh
popd
UPGRADE_PLAYBOOKS="${UPGRADE_UTILS}-kilo/playbooks"
RUN_TASKS=()
RUN_TASKS+=("${UPGRADE_PLAYBOOKS}/user-secrets-adjustments-kilo.yml -e 'osa_playbook_dir=/opt/leap42/openstack-ansible-${KILO_RELEASE}'")
RUN_TASKS+=("${UPGRADE_PLAYBOOKS}/host-adjustments.yml")
RUN_TASKS+=("${UPGRADE_PLAYBOOKS}/remove-juno-log-rotate.yml || true")
if [ "$(ansible 'swift_hosts' --list-hosts)" != "No hosts matched" ]; then
RUN_TASKS+=("${UPGRADE_PLAYBOOKS}/swift-ring-adjustments.yml")
RUN_TASKS+=("${UPGRADE_PLAYBOOKS}/swift-repo-adjustments.yml")
fi
run_items "/opt/leap42/openstack-ansible-${KILO_RELEASE}"
tag_leap_success "${KILO_RELEASE}-prep"
fi
### Kilo System migration
### Liberty System migration
# Run tasks
if [[ ! -f "/opt/leap42/openstack-ansible-${LIBERTY_RELEASE}.leap" ]]; then
notice 'Running liberty leap'
link_release "/opt/leap42/openstack-ansible-${LIBERTY_RELEASE}"
UPGRADE_PLAYBOOKS="${UPGRADE_UTILS}-liberty/playbooks"
RUN_TASKS=()
RUN_TASKS+=("${UPGRADE_PLAYBOOKS}/ansible_fact_cleanup-liberty.yml")
RUN_TASKS+=("${UPGRADE_PLAYBOOKS}/deploy-config-changes-liberty.yml -e 'osa_playbook_dir=/opt/leap42/openstack-ansible-${LIBERTY_RELEASE}'")
RUN_TASKS+=("${UPGRADE_PLAYBOOKS}/user-secrets-adjustment-liberty.yml -e 'osa_playbook_dir=/opt/leap42/openstack-ansible-${LIBERTY_RELEASE}'")
RUN_TASKS+=("${UPGRADE_PLAYBOOKS}/mariadb-apt-cleanup.yml")
RUN_TASKS+=("${UPGRADE_PLAYBOOKS}/disable-neutron-port-security.yml")
run_items "/opt/leap42/openstack-ansible-${LIBERTY_RELEASE}"
tag_leap_success "${LIBERTY_RELEASE}-prep"
fi
### Liberty System migration
### Mitaka System migration
# Run tasks
if [[ ! -f "/opt/leap42/openstack-ansible-${MITAKA_RELEASE}.leap" ]]; then
notice 'Running mitaka leap'
link_release "/opt/leap42/openstack-ansible-${MITAKA_RELEASE}"
UPGRADE_PLAYBOOKS="${UPGRADE_UTILS}-mitaka/playbooks"
RUN_TASKS=()
RUN_TASKS+=("${UPGRADE_PLAYBOOKS}/ansible_fact_cleanup-mitaka-1.yml")
RUN_TASKS+=("${UPGRADE_PLAYBOOKS}/deploy-config-changes-mitaka.yml -e 'osa_playbook_dir=/opt/leap42/openstack-ansible-${MITAKA_RELEASE}'")
RUN_TASKS+=("${UPGRADE_PLAYBOOKS}/user-secrets-adjustment-mitaka.yml -e 'osa_playbook_dir=/opt/leap42/openstack-ansible-${MITAKA_RELEASE}'")
RUN_TASKS+=("${UPGRADE_PLAYBOOKS}/pip-conf-removal.yml")
RUN_TASKS+=("${UPGRADE_PLAYBOOKS}/old-hostname-compatibility-mitaka.yml")
RUN_TASKS+=("${UPGRADE_PLAYBOOKS}/ansible_fact_cleanup-mitaka-2.yml")
run_items "/opt/leap42/openstack-ansible-${MITAKA_RELEASE}"
tag_leap_success "${MITAKA_RELEASE}-prep"
fi
### Mitaka System migration
### Newton Deploy
# Run tasks
if [[ ! -f "/opt/leap42/openstack-ansible-${NEWTON_RELEASE}.leap" ]]; then
notice 'Running newton leap'
link_release "/opt/leap42/openstack-ansible-${NEWTON_RELEASE}"
UPGRADE_PLAYBOOKS="${UPGRADE_UTILS}-newton/playbooks"
RUN_TASKS=()
RUN_TASKS+=("${UPGRADE_PLAYBOOKS}/lbaas-version-check.yml")
RUN_TASKS+=("${UPGRADE_PLAYBOOKS}/ansible_fact_cleanup-newton.yml")
RUN_TASKS+=("${UPGRADE_PLAYBOOKS}/deploy-config-changes-newton.yml -e 'osa_playbook_dir=/opt/leap42/openstack-ansible-${NEWTON_RELEASE}'")
RUN_TASKS+=("${UPGRADE_PLAYBOOKS}/user-secrets-adjustment-newton.yml -e 'osa_playbook_dir=/opt/leap42/openstack-ansible-${NEWTON_RELEASE}'")
RUN_TASKS+=("${UPGRADE_PLAYBOOKS}/old-hostname-compatibility-newton.yml")
run_items "/opt/leap42/openstack-ansible-${NEWTON_RELEASE}"
tag_leap_success "${NEWTON_RELEASE}-prep"
fi
### Run host upgrade
notice 'Running host upgrade'
link_release "/opt/leap42/openstack-ansible-${NEWTON_RELEASE}"
RUN_TASKS=()
RUN_TASKS+=("${UPGRADE_UTILS}/pip-conf-purge.yml")
RUN_TASKS+=("openstack-hosts-setup.yml")
run_items "/opt/openstack-ansible"
### Run host upgrade