Iterate over all templates which need NW template migration.

There is a bug with the logic that takes care of migrating the
NW templates from one version to another. As it is right now,
it was only performing the NW template migration of the last
file it found a Net::SoftwareConfig in. Causing issues if
more than one template from overcloud_deploy script contained.

This patch loops over all the outputs from nic_config_envs and
for each match it will run the script to migrate the templates.

Change-Id: I1456f55d18d9e87782e0f6d5232bdee7f8a85fb8
This commit is contained in:
Jose Luis Franco Arza 2020-08-13 17:41:54 +02:00 committed by Jose Luis Franco
parent e37b0aea7c
commit b4e8adab42
2 changed files with 33 additions and 31 deletions

View File

@ -0,0 +1,32 @@
---
- name: set nic_config_env fact
set_fact:
nic_config_env: "{{ item.item }}"
when: item.stdout|length > 0
- block:
- name: register nic templates files defined in the environment file
shell: |
set -o pipefail
awk -F': ' '/OS::TripleO::.*::Net::SoftwareConfig/ {print $2}' {{ nic_config_env }}
register: nic_template_files
- name: run parameters conversion script
vars:
relative_path: "{{ '/'.join(nic_config_env.split('/')[0:-1]) + '/' + item }}"
nic_path: "{{ (item[0] == '/')|ternary(item, relative_path) }}"
shell: |
set -o pipefail
NIC_ROLE_NAME=$( grep {{ item }} {{ nic_config_env }} | awk -F '::' '{ print $3 }' );
/usr/share/openstack-tripleo-heat-templates/tools/merge-new-params-nic-config-script.py \
--tht-dir {{ tht_directory }} \
--role-name $NIC_ROLE_NAME \
--roles-data {{ roles_data }} \
--discard-comments yes \
--template {{ nic_path }}
when:
- "(item[0] == '/' and tht_directory not in item) or \
(item[0] != '/' and tht_directory not in '/'.join(nic_config_env.split('/')[0:-1]))"
loop: "{{ nic_template_files.stdout_lines }}"
when: nic_config_env is defined

View File

@ -6,35 +6,5 @@
register: nic_config_envs
loop: "{{ initial_env_file.stdout_lines }}"
- name: set nic_config_env fact
set_fact:
nic_config_env: "{{ item.item }}"
when: item.stdout|length > 0
- include_tasks: convert_nic_template.yaml
loop: "{{ nic_config_envs.results }}"
- block:
- name: register nic templates files defined in the environment file
shell: |
set -o pipefail
awk -F': ' '/OS::TripleO::.*::Net::SoftwareConfig/ {print $2}' {{ nic_config_env }}
register: nic_template_files
- name: run parameters conversion script
vars:
relative_path: "{{ '/'.join(nic_config_env.split('/')[0:-1]) + '/' + item }}"
nic_path: "{{ (item[0] == '/')|ternary(item, relative_path) }}"
shell: |
set -o pipefail
NIC_ROLE_NAME=$( grep {{ item }} {{ nic_config_env }} | awk -F '::' '{ print $3 }' );
/usr/share/openstack-tripleo-heat-templates/tools/merge-new-params-nic-config-script.py \
--tht-dir {{ tht_directory }} \
--role-name $NIC_ROLE_NAME \
--roles-data {{ roles_data }} \
--discard-comments yes \
--template {{ nic_path }}
when:
- "(item[0] == '/' and tht_directory not in item) or \
(item[0] != '/' and tht_directory not in '/'.join(nic_config_env.split('/')[0:-1]))"
loop: "{{ nic_template_files.stdout_lines }}"
when: nic_config_env is defined