Skip to content

Commit

Permalink
Merge pull request #323 from antonym/generate_upgrade_configs
Browse files Browse the repository at this point in the history
Adds an Ansible playbook for user_rpco_upgrade.yml
  • Loading branch information
antonym authored Jan 31, 2019
2 parents 4aa1c99 + 77c46d8 commit a513c93
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 44 deletions.
3 changes: 3 additions & 0 deletions incremental/incremental-upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ if ! echo ${TODO} | grep -w ${TARGET} > /dev/null; then
fi

check_user_variables
generate_upgrade_config

if [ "${SKIP_PREFLIGHT}" != "true" ]; then
pre_flight
Expand All @@ -73,3 +74,5 @@ for RELEASE_TO_DO in ${TODO}; do
echo "Starting upgrade to ${RELEASE_TO_DO^}"
bash ubuntu16-upgrade-to-${RELEASE_TO_DO}.sh
done

cleanup
47 changes: 13 additions & 34 deletions incremental/lib/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -153,40 +153,6 @@ function install_ansible_source {
/opt/rpc-ansible/bin/pip install --isolated "ansible==${RPC_ANSIBLE_VERSION}"
}

function set_keystone_flush_memcache {
if [[ ! -f /etc/openstack_deploy/user_rpco_upgrade.yml ]]; then
echo "---" > /etc/openstack_deploy/user_rpco_upgrade.yml
echo "keystone_flush_memcache: yes" >> /etc/openstack_deploy/user_rpco_upgrade.yml
elif [[ -f /etc/openstack_deploy/user_rpco_upgrade.yml ]]; then
if ! grep -i "keystone_flush_memcache" /etc/openstack_deploy/user_rpco_upgrade.yml; then
echo "keystone_flush_memcache: yes" >> /etc/openstack_deploy/user_rpco_upgrade.yml
fi
fi
}

function disable_hardening {
if [[ ! -f /etc/openstack_deploy/user_rpco_upgrade.yml ]]; then
echo "---" > /etc/openstack_deploy/user_rpco_upgrade.yml
echo "apply_security_hardening: false" >> /etc/openstack_deploy/user_rpco_upgrade.yml
elif [[ -f /etc/openstack_deploy/user_rpco_upgrade.yml ]]; then
if ! grep -i "apply_security_hardening" /etc/openstack_deploy/user_rpco_upgrade.yml; then
echo "apply_security_hardening: false" >> /etc/openstack_deploy/user_rpco_upgrade.yml
fi
fi
}

function set_secrets_file {
if [ -f "/etc/openstack_deploy/user_secrets.yml" ]; then
if ! grep "^osa_secrets_file_name" /etc/openstack_deploy/user_rpco_upgrade.yml; then
echo 'osa_secrets_file_name: "user_secrets.yml"' >> /etc/openstack_deploy/user_rpco_upgrade.yml
fi
elif [ -f "/etc/openstack_deploy/user_osa_secrets.yml" ]; then
if ! grep "^osa_secrets_file_name" /etc/openstack_deploy/user_rpco_upgrade.yml; then
echo 'osa_secrets_file_name: "user_osa_secrets.yml"' >> /etc/openstack_deploy/user_rpco_upgrade.yml
fi
fi
}

function run_upgrade {
pushd /opt/openstack-ansible
export TERM=linux
Expand All @@ -205,6 +171,13 @@ function strip_install_steps {
popd
}

function generate_upgrade_config {
# generate user_rpco_upgrade.yml
pushd /opt/rpc-upgrades/incremental/playbooks
openstack-ansible rpco-upgrade-configs.yml
popd
}

function prepare_ocata {
if [[ ! -f "/etc/openstack_deploy/ocata_upgrade_prep.complete" ]]; then
pushd /opt/rpc-upgrades/incremental/playbooks
Expand Down Expand Up @@ -241,3 +214,9 @@ function prepare_queens {
function prepare_rocky {
echo "Rocky prepare steps go here..."
}

function cleanup {
if [ -f "/etc/openstack_deploy/user_rpco_upgrade.yml" ]; then
rm /etc/openstack_deploy/user_rpco_upgrade.yml
fi
}
109 changes: 109 additions & 0 deletions incremental/playbooks/rpco-upgrade-configs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
---
# Copyright 2019, 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.

- name: Generate user_rpco_upgrade.yml for upgrade duration
hosts: localhost
user: root
vars:
upgrade_config_file: /etc/openstack_deploy/user_rpco_upgrade.yml
tasks:
- name: Ensure user_rpco_upgrade.yml exists
file:
path: "{{ upgrade_config_file }}"
state: touch

- name: Check if user_secrets exists
stat:
path: /etc/openstack_deploy/user_secrets.yml
register: user_secrets

- name: Check if user_osa_secrets exists
stat:
path: /etc/openstack_deploy/user_osa_secrets.yml
register: user_osa_secrets

- name: Set osa_secrets_file_name to user_secrets
lineinfile:
dest: "{{ upgrade_config_file }}"
regexp: "{{ item.regexp | default('^' + item.key) }}"
line: "{{ item.key }}: {{ item.value }}"
state: present
with_items:
- key: "osa_secrets_file_name"
value: "user_secrets.yml"
when: user_secrets.stat.exists

- name: Set osa_secrets_file_name to user_osa_secrets
lineinfile:
dest: "{{ upgrade_config_file }}"
regexp: "{{ item.regexp | default('^' + item.key) }}"
line: "{{ item.key }}: {{ item.value }}"
state: present
with_items:
- key: "osa_secrets_file_name"
value: "user_osa_secrets.yml"
when: user_osa_secrets.stat.exists

- name: Flush keystone memcache
lineinfile:
dest: "{{ upgrade_config_file }}"
regexp: "{{ item.regexp | default('^' + item.key) }}"
line: "{{ item.key }}: {{ item.value }}"
state: present
with_items:
- key: "keystone_flush_memcache"
value: "yes"

- name: Disable hardening for upgrade
lineinfile:
dest: "{{ upgrade_config_file }}"
regexp: "{{ item.regexp | default('^' + item.key) }}"
line: "{{ item.key }}: {{ item.value }}"
state: present
with_items:
- key: "apply_security_hardening"
value: "false"

- name: Remove serialization throttle for upgrade
lineinfile:
dest: "{{ upgrade_config_file }}"
regexp: "{{ item.regexp | default('^' + item.key) }}"
line: "{{ item.key }}: {{ item.value }}"
state: present
with_items:
- key: "nova_compute_serial"
value: "100%"
- key: "nova_conductor_serial"
value: "100%"
- key: "nova_console_serial"
value: "100%"
- key: "nova_scheduler_serial"
value: "100%"
- key: "nova_api_serial"
value: "100%"
- key: "neutron_agent_serial"
value: "100%"
- key: "neutron_server_serial"
value: "100%"
- key: "neutron_other_serial"
value: "100%"
- key: "cinder_backend_serial"
value: "100%"
- key: "cinder_scheduler_serial"
value: "100%"
- key: "glance_api_serial"
value: "100%"
- key: "glance_registry_rolling"
value: "100%"
3 changes: 0 additions & 3 deletions incremental/ubuntu16-upgrade-to-ocata.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ prepare_ocata

checkout_rpc_openstack
checkout_openstack_ansible
set_secrets_file
disable_hardening
set_keystone_flush_memcache

if [[ "$SKIP_INSTALL" == "yes" ]]; then
exit 0
Expand Down
3 changes: 0 additions & 3 deletions incremental/ubuntu16-upgrade-to-pike.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ echo "Starting Ocata to Pike Upgrade..."

checkout_rpc_openstack
configure_rpc_openstack
set_secrets_file
disable_hardening
set_keystone_flush_memcache
prepare_pike

if [[ "$SKIP_INSTALL" == "yes" ]]; then
Expand Down
2 changes: 0 additions & 2 deletions incremental/ubuntu16-upgrade-to-queens.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ echo "Starting Pike to Queens Upgrade..."

checkout_rpc_openstack
configure_rpc_openstack
set_secrets_file
disable_hardening
prepare_queens
run_upgrade

Expand Down
2 changes: 0 additions & 2 deletions incremental/ubuntu16-upgrade-to-rocky.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ echo "Starting Queens to Rocky Upgrade..."

checkout_rpc_openstack
configure_rpc_openstack
set_secrets_file
disable_hardening
prepare_rocky
run_upgrade

Expand Down

0 comments on commit a513c93

Please sign in to comment.