From 4458ab622a71b5f86b103df0924817fc3f457b2f Mon Sep 17 00:00:00 2001 From: Luigi Toscano Date: Thu, 29 Apr 2021 14:19:49 +0200 Subject: [PATCH] [ffwd] Allow users to replace environment files A new option allows user to replace the content of specific environment files which are listed in the "overcloud deploy" bash script which is parsed and used here. This is useful when the content of a file is known to have changed between the source and destination release. The feature is implemented for FFWD only right now, but it could be used for any kind of upgrade/update process. Change-Id: I027770e0ac8c73896d2b57218da3a5063b9707fd --- infrared_plugin/plugin.spec | 7 +++++++ tasks/common/replace_environment_file.yaml | 19 +++++++++++++++++++ tasks/common/replace_environment_files.yaml | 4 ++++ tasks/fast-forward-upgrade/main.yml | 4 ++++ 4 files changed, 34 insertions(+) create mode 100644 tasks/common/replace_environment_file.yaml create mode 100644 tasks/common/replace_environment_files.yaml diff --git a/infrared_plugin/plugin.spec b/infrared_plugin/plugin.spec index b8ef4de1..7258a7c8 100644 --- a/infrared_plugin/plugin.spec +++ b/infrared_plugin/plugin.spec @@ -300,6 +300,13 @@ subparsers: help: | Fast Forward Upgrade compute nodes one by one default: false + overcloud-ffu-replace-env-files: + type: KeyValueList + help: | + A comma-separated list of key/values which describe the environment files + whose content should be replaced during the upgrade phase. + The value must be the path to the new file, while the key must match + the file name to replaced as it shows inside the deploy script. - title: Set up FFU packages options: mirror: diff --git a/tasks/common/replace_environment_file.yaml b/tasks/common/replace_environment_file.yaml new file mode 100644 index 00000000..8c740568 --- /dev/null +++ b/tasks/common/replace_environment_file.yaml @@ -0,0 +1,19 @@ +--- +- name: determine the name of the replaced environment file + shell: + cat {{ overcloud_deploy_script }} | grep '-e .\+{{ item.key }} ' | sed 's/.\+ \(.\+{{ item.key }}\) .*/\1/' + register: ffu_replaced_env_file + +- block: + - name: save a copy of the replaced environment configuration file + copy: + remote_src: true + src: "{{ ffu_replaced_env_file.stdout }}" + dest: "{{ ffu_replaced_env_file.stdout }}.orig.yaml" + + - name: replace the environment configuration file with the new one + copy: + src: "{{ item.value }}" + dest: "{{ ffu_replaced_env_file.stdout }}" + + when: ffu_replaced_env_file.stdout|length > 0 diff --git a/tasks/common/replace_environment_files.yaml b/tasks/common/replace_environment_files.yaml new file mode 100644 index 00000000..fb1e6f18 --- /dev/null +++ b/tasks/common/replace_environment_files.yaml @@ -0,0 +1,4 @@ +--- +- name: loop over the replacement environment configuration files + include_tasks: replace_environment_file.yaml + loop: "{{ install.overcloud.ffu.replace.env.files | default({}) | dict2items }}" diff --git a/tasks/fast-forward-upgrade/main.yml b/tasks/fast-forward-upgrade/main.yml index c88f6755..a742af84 100644 --- a/tasks/fast-forward-upgrade/main.yml +++ b/tasks/fast-forward-upgrade/main.yml @@ -135,6 +135,10 @@ import_tasks: convert_tls_templates.yaml tags: ffu_overcloud_prepare + - name: replace environment files + import_tasks: ../common/replace_environment_files.yaml + tags: ffu_overcloud_prepare + - name: run overcloud upgrade prepare import_tasks: ../upgrade/overcloud_upgrade_prepare.yml tags: ffu_overcloud_prepare