Check repo setup script exists before content load.

In [0] there was an attempt to bypass the case
in which the repo setup script was not created
by using the Ansible lookup 'first_found'. However,
this lookup doesn't return the content of the file,
as the 'file' lookup does. It returns the name of
the file if the file exists.

This patch adds an Ansible step that checks the
existence of the repo setup script and loads the
content of the file if it exists, otherwise sets
the variable to false.

[0] https://review.openstack.org/#/c/549179/4

Change-Id: Iecf1534afff2bf3df4e2bfc23d0969fb57566b66
Closes-Bug: #1756037
This commit is contained in:
Jose Luis Franco Arza 2018-03-15 11:52:08 +01:00
parent 8474990f4a
commit eaa3fd0d62
1 changed files with 11 additions and 2 deletions

View File

@ -29,13 +29,22 @@
tags:
- overcloud-upgrade
vars:
update_repo_script: "{{ lookup('first_found', dict(files=['{{ working_dir }}/repo-setup-{{ target_upgrade_version }}.sh'], skip=true)) }}"
repo_setup_script: "{{ working_dir }}/repo-setup-{{ target_upgrade_version }}.sh"
tripleo_upgrade_branch: "{{ 'stable/'+target_upgrade_version if target_upgrade_version!='master' else target_upgrade_version }}"
tasks:
- name: Filter ansible_br_*
setup:
filter: ansible_br_*
- name: Check repo setup script exists
stat:
path: "{{ repo_setup_script }}"
register: repo_script_status
- name: Set fact with repo script content or false
set_fact:
update_repo_script_content: "{% if repo_script_status.stat.exists %}{{ lookup('file', repo_setup_script) }}{% else %}false{% endif %}"
- name: Copy current T-H-T directory to the upgrade working dir
synchronize:
src: /usr/share/openstack-tripleo-heat-templates
@ -64,7 +73,7 @@
- name: Run Tripleo-upgrade role
vars:
upgrade_init_command: "{{ update_repo_script }}"
upgrade_init_command: "{{ update_repo_script_content }}"
include_role:
name: tripleo-upgrade
when: containerized_overcloud_upgrade|bool or undercloud_upgrade|default(false)|bool