Files
openstack-ansible/scripts/upgrade-utilities/deploy-config-changes.yml
Jesse Pretorius cd32d15cc0 Add nova placement to placement migration
In order to facilitate the nova placement -> extracted placement
migration, while keeping the services up for as long as possible,
we combine the two groups for the load balancer configuration on
the first pass, and pass the appropriate flag for the openstack
playbook to handle the migration. Once it's all done, we re-run
the haproxy playbook without the flag to ensure that the old nova
placement backends are removed.

We also remove haproxy_nova_placement_whitelist_networks as it is
no longer used anywhere.

Change-Id: I85e9182e7c4fe9477d30dd16b4132c1645205cce
2019-10-08 19:03:15 +00:00

126 lines
4.6 KiB
YAML

---
# 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: Prepare environment and configuration for deploying the new release
hosts: localhost
connection: local
gather_facts: false
user: root
vars:
repo_root_dir: "{{ (playbook_dir ~ '/../../') | realpath }}"
ansible_python_interpreter: "/usr/bin/python"
tasks:
- name: Remove unnecessary env.d override files
shell: |
set -e
exit_code=0
if [[ -e /etc/openstack_deploy/env.d ]]; then
for f in $(diff --brief --report-identical-files /etc/openstack_deploy/env.d /opt/openstack-ansible/inventory/env.d | awk '/identical/ {print $2}' 2>/dev/null); do
echo "Deleting ${f} because it is identical to the defaults."
rm -f ${f}
exit_code=2
done
fi
exit ${exit_code}
args:
executable: /bin/bash
register: _envd_dir_cleanup
changed_when: _envd_dir_cleanup.rc == 2
failed_when: _envd_dir_cleanup.rc not in [0,2]
tags:
- identical-envd-file-cleanup
- name: Find any config files in the user-space env.d directory
find:
paths:
- "/etc/openstack_deploy/env.d"
patterns: '*.yml'
register: _envd_dir_contents
tags:
- custom-envd-file-check
- name: Halt the upgrade and warn the user to inspect the env.d files for changes
fail:
msg: |
There are files in /etc/openstack_deploy/env.d which override the default inventory
layout in {{ repo_root_dir }}/inventory/env.d. The difference between these files
should be carefully reviewed to understand whether the changes are still necessary
and applicable to the environment. If all the user-space env.d files are necessary,
then please export SKIP_CUSTOM_ENVD_CHECK=true and re-run the playbook or
run-upgrade.sh script.
when:
- _envd_dir_contents.matched > 0
- not(lookup('env', 'SKIP_CUSTOM_ENVD_CHECK') | bool)
tags:
- custom-envd-file-check
- name: Read example user secrets file
shell: "grep '^[a-zA-Z]' {{ repo_root_dir }}/etc/openstack_deploy/user_secrets.yml"
register: new_secrets
tags:
- update-secrets
- name: Read existing user secrets file
shell: "grep '^[a-zA-Z]' /etc/openstack_deploy/user_secrets.yml"
register: user_secrets
tags:
- update-secrets
- name: Add missing secrets
lineinfile:
dest: "/etc/openstack_deploy/user_secrets.yml"
line: "{{ item }}"
with_items: "{{ new_secrets.stdout_lines }}"
when:
- not (user_secrets.stdout | regex_search('((^|\n)' ~ item ~ ')'))
tags:
- update-secrets
- name: Generate new secrets
shell: "{{ repo_root_dir }}/scripts/pw-token-gen.py --file /etc/openstack_deploy/user_secrets.yml"
tags:
- update-secrets
- name: Remove fact cache to ensure a fresh one is built during the upgrade
file:
path: "/etc/openstack_deploy/ansible_facts"
state: absent
tags:
- remove-fact-cache
- name: Define placement service hosts
copy:
dest: /etc/openstack_deploy/conf.d/placement.yml
content: |-
{% set config = {'placement-infra_hosts': {}} %}
{% for host in groups['compute-infra_hosts'] %}
{% set _ = config['placement-infra_hosts'].update(
{
host: {
'ip': hostvars[host]['container_address']
}
}
) %}
{% endfor %}
{{ config | to_yaml }}
when:
- placement_migrate_flag | default(False)
- not ('placement-infra_hosts' in groups and groups['placement-infra_hosts'])
- name: Set placement service is_metal property
copy:
dest: /etc/openstack_deploy/env.d/placement_metal.yml
content: "{{ '---\n' ~ {'container_skel': {'placement_container': {'properties': {'is_metal': true}}}} | to_yaml }}"
when:
- placement_migrate_flag | default(False)
- hostvars[groups['nova_api_placement'][0]]['is_metal'] | default(False)