diff --git a/scripts/run-upgrade.sh b/scripts/run-upgrade.sh new file mode 100755 index 0000000000..59232fe702 --- /dev/null +++ b/scripts/run-upgrade.sh @@ -0,0 +1,525 @@ +#!/usr/bin/env bash +# Copyright 2015, 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. + +## Pre-flight Check ---------------------------------------------------------- +# Clear the screen and make sure the user understands whats happening. +clear + +# NOTICE: To run this in an automated fashion run the script via +# root@HOSTNAME:/opt/os-ansible-deployment# echo "YES" | bash scripts/upgrade-v10-2-v11.sh + +# Notify the user. +echo -e " +This script will perform a v10.x to v11.x upgrade. +Once you start the upgrade there's no going back. + +Note, this is an online upgrade and while the +in progress running VMs will not be impacted. +However, you can expect some hiccups with OpenStack +API services while the upgrade is running. + +Are you ready to perform this upgrade now? +" + +# Confirm the user is ready to upgrade. +read -p 'Enter "YES" to continue or anything else to quit: ' UPGRADE +if [ "${UPGRADE}" == "YES" ]; then + echo "Running Upgrade from v10.x to v11.x" +else + exit 99 +fi + +## Shell Opts ---------------------------------------------------------------- +set -e -u -v + +## Library Check ------------------------------------------------------------- +info_block "Checking for required libraries." 2> /dev/null || source $(dirname ${0})/scripts-library.sh + +## Functions ----------------------------------------------------------------- +function get_inv_items(){ + ./scripts/inventory-manage.py -f /etc/openstack_deploy/openstack_inventory.json -l | grep -w ".*$1" +} + +function remove_inv_items(){ + ./scripts/inventory-manage.py -f /etc/openstack_deploy/openstack_inventory.json -r "$1" +} + +## Main ---------------------------------------------------------------------- + +# Create new openstack_deploy directory. +if [ -d "/etc/rpc_deploy" ];then + # Create an archive of the old deployment directory + tar -czf ~/pre-upgrade-backup.tgz /etc/rpc_deploy + # Move the new deployment directory bits into place + mkdir -p /etc/openstack_deploy/ + cp -R /etc/rpc_deploy/* /etc/openstack_deploy/ + mv /etc/rpc_deploy /etc/rpc_deploy.OLD +else + echo "No /etc/rpc_deploy directory found, thus nothing to upgrade." + exit 1 +fi + +# Drop deprecation file. +cat > /etc/rpc_deploy.OLD/DEPRECATED.txt <> /etc/openstack_deploy/user_secrets.yml < /tmp/fix_minor_adjustments.yml < + chown -R "{{ horizon_system_user_name }}":"{{ horizon_system_group_name }}" "/usr/local/lib/python2.7/dist-packages/static" + register: horizon_cmd_chown + failed_when: false + changed_when: horizon_cmd_chown.rc == 0 + vars: + horizon_system_user_name: "horizon" + horizon_system_group_name: "www-data" + horizon_system_shell: "/bin/false" + horizon_system_comment: "horizon system user" + horizon_system_user_home: "/var/lib/{{ horizon_system_user_name }}" +- name: Fix keystone things + hosts: "keystone_all" + gather_facts: false + user: root + tasks: + - name: Fix keystone permissions + command: > + chown -R "keystone":"keystone" "/var/log/keystone" + register: keystone_cmd_chown + failed_when: false + changed_when: keystone_cmd_chown.rc == 0 +EOF + +# Create a play to fix host things +cat > /tmp/fix_host_things.yml < /tmp/fix_container_interfaces.yml < /tmp/fix_swift_rings_locations.yml < + inventory_hostname == groups['swift_hosts'][0] + vars: + swift_system_user_name: swift + swift_system_group_name: swift + swift_system_shell: /bin/bash + swift_system_comment: swift system user + swift_system_home_folder: "/var/lib/{{ swift_system_user_name }}" +EOF + +pushd playbooks + # Reconfig haproxy if setup. + if grep '^haproxy_hosts\:' /etc/openstack_deploy/openstack_user_config.yml;then + ansible haproxy_hosts \ + -m shell \ + -a 'rm /etc/haproxy/conf.d/nova_api_ec2 /etc/haproxy/conf.d/nova_spice_console' + openstack-ansible haproxy-install.yml + fi + + # Run the fix adjustments play. + openstack-ansible /tmp/fix_minor_adjustments.yml + # Remove fix container adjustments play + rm /tmp/fix_minor_adjustments.yml + + # Run the fix host things play + openstack-ansible /tmp/fix_host_things.yml + # Remove fix host things play + rm /tmp/fix_host_things.yml + + # Run the fix for container networks. Forces True as containers may not exist at this point + openstack-ansible /tmp/fix_container_interfaces.yml || true + # Remove fix container networks play + rm /tmp/fix_container_interfaces.yml + + # Send the swift rings to the first swift host if swift was installed in "v10.x". + if [ "$(ansible 'swift_hosts' --list-hosts)" != "No hosts matched" ] && [ -d "/etc/swift/rings" ];then + openstack-ansible /tmp/fix_swift_rings_locations.yml + # Remove fix swift rings locations play + rm /tmp/fix_swift_rings_locations.yml + fi + + # Rerun create containers that will update all running containers with the new bits + openstack-ansible lxc-containers-create.yml + + # With inventory and containers upgraded run the remaining host setup + openstack-ansible openstack-hosts-setup.yml + + # Now run the infrastructure setup + openstack-ansible setup-infrastructure.yml + + # Now upgrade the rest of OpenStack + openstack-ansible setup-openstack.yml +popd