Make upgrade script respect OSA_CONFIG_DIR

This also adds variable `openstack_clone_root` which equals to
environment variable $OSA_CLONE_ROOT and defaults to `/opt/openstack-ansible`.

Change-Id: I9e0c980f80980c389e27d5b54077b08a596a33f4
This commit is contained in:
Dmitriy Rabotyagov 2019-12-09 13:33:29 +02:00
parent 396cb8a9fc
commit be89da6a13
2 changed files with 11 additions and 9 deletions

View File

@ -19,6 +19,9 @@ openstack_release: "{{ lookup('env', 'OSA_VERSION') | default('undefined', true)
## OpenStack Configuration directory ## OpenStack Configuration directory
openstack_config_dir: "{{ lookup('env', 'OSA_CONFIG_DIR') | default('/etc/openstack_deploy') }}" openstack_config_dir: "{{ lookup('env', 'OSA_CONFIG_DIR') | default('/etc/openstack_deploy') }}"
## OpenStack Clone directory
openstack_clone_root: "{{ (lookup('env', 'OSA_CLONE_ROOT') | default('/opt/openstack-ansible', true)) }}"
## OpenStack service python version ## OpenStack service python version
openstack_venv_python_executable: "{{ (ansible_distribution == 'CentOS') | ternary('python2', 'python3') }}" openstack_venv_python_executable: "{{ (ansible_distribution == 'CentOS') | ternary('python2', 'python3') }}"
@ -138,8 +141,7 @@ is_metal: >-
(properties.is_metal is defined) and (properties.is_metal is defined) and
(properties.is_metal | bool) }} (properties.is_metal | bool) }}
_global_pins_file_path: >- _global_pins_file_path: "{{ openstack_clone_root }}/global-requirement-pins.txt"
{{ (lookup('env', 'OSA_CLONE_ROOT') | default('/opt/openstack-ansible', true)) ~ '/global-requirement-pins.txt' }}
venv_build_global_constraints: >- venv_build_global_constraints: >-
{{ lookup('file', _global_pins_file_path).splitlines() | reject('match','^#.*$') | reject('equalto', '') | list }} {{ lookup('file', _global_pins_file_path).splitlines() | reject('match','^#.*$') | reject('equalto', '') | list }}

View File

@ -24,8 +24,8 @@
shell: | shell: |
set -e set -e
exit_code=0 exit_code=0
if [[ -e /etc/openstack_deploy/env.d ]]; then if [[ -e {{ openstack_config_dir }}/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 for f in $(diff --brief --report-identical-files {{ openstack_config_dir }}/env.d {{ openstack_clone_root }}/inventory/env.d | awk '/identical/ {print $2}' 2>/dev/null); do
echo "Deleting ${f} because it is identical to the defaults." echo "Deleting ${f} because it is identical to the defaults."
rm -f ${f} rm -f ${f}
exit_code=2 exit_code=2
@ -43,7 +43,7 @@
- name: Find any config files in the user-space env.d directory - name: Find any config files in the user-space env.d directory
find: find:
paths: paths:
- "/etc/openstack_deploy/env.d" - "{{ openstack_config_dir }}/env.d"
patterns: '*.yml' patterns: '*.yml'
register: _envd_dir_contents register: _envd_dir_contents
tags: tags:
@ -71,14 +71,14 @@
- update-secrets - update-secrets
- name: Read existing user secrets file - name: Read existing user secrets file
shell: "grep '^[a-zA-Z]' /etc/openstack_deploy/user_secrets.yml" shell: "grep '^[a-zA-Z]' {{ openstack_config_dir }}/user_secrets.yml"
register: user_secrets register: user_secrets
tags: tags:
- update-secrets - update-secrets
- name: Add missing secrets - name: Add missing secrets
lineinfile: lineinfile:
dest: "/etc/openstack_deploy/user_secrets.yml" dest: "{{ openstack_config_dir }}/user_secrets.yml"
line: "{{ item }}" line: "{{ item }}"
with_items: "{{ new_secrets.stdout_lines }}" with_items: "{{ new_secrets.stdout_lines }}"
when: when:
@ -87,13 +87,13 @@
- update-secrets - update-secrets
- name: Generate new secrets - name: Generate new secrets
shell: "{{ repo_root_dir }}/scripts/pw-token-gen.py --file /etc/openstack_deploy/user_secrets.yml" shell: "{{ repo_root_dir }}/scripts/pw-token-gen.py --file {{ openstack_config_dir }}/user_secrets.yml"
tags: tags:
- update-secrets - update-secrets
- name: Remove fact cache to ensure a fresh one is built during the upgrade - name: Remove fact cache to ensure a fresh one is built during the upgrade
file: file:
path: "/etc/openstack_deploy/ansible_facts" path: "{{ openstack_config_dir }}/ansible_facts"
state: absent state: absent
tags: tags:
- remove-fact-cache - remove-fact-cache