Set up right DNF module stream for Upgrades and Updates.

To ensure we get the right package versions we need to
make sure the right stream is configured for the
container-tools module.

This patch leverages the dnf module, which when passing as name
the @ identifier allows us to enable a stream for some specific
module [0], configuring the stream passed in DnfStreams heat parameter
in updates/upgrades task for step0.

If the stream passed in such parameter is alredy set, then the
module won't do anything else. On the contrary, it will disable
the current stream, enable the ones from DnfStreams and synchronize
the content.

By default the new Heat parameter defaults to empty list and it is
in the environment files where we set the right values depending
on the operation to perform (undercloud upgrade, overcloud update
or overcloud upgrade).

*****************************************************************
*BACKPORT NOTE: Add DNF module stream virt:8.2 in the overcloud *
*upgrade/update environment files.                              *
*****************************************************************

[0] - https://docs.ansible.com/ansible/latest/modules/dnf_module.html#examples
Closes-Bug: #1890631
Resolves: rhbz#1866479

Change-Id: Ib388af0a06bbb6172593dc2fd19748b770b2e335
This commit is contained in:
Jose Luis Franco Arza 2020-08-06 22:01:49 +02:00
parent efd1975513
commit 4c2d5927e6
5 changed files with 49 additions and 0 deletions

View File

@ -91,6 +91,13 @@ parameters:
Mainly for CI purpose. It shouldn't matter on other distributions
where it's disabled in the role. Set to true to skip the enforcement.
type: string
DnfStreams:
default: []
description: List of streams to be configured before updating packages. Each list
element contains a dictionary with the following values defined
module[mandatory], stream[mandatory] and profile[optional]. If the profile
is not specified 'common' will be used instead.
type: json
outputs:
role_data:
@ -223,6 +230,16 @@ outputs:
- ''
- - "#!/bin/bash\n\n"
- {get_param: UpgradeInitCommonCommand}
- name: Ensure DNF modules have the right stream
vars:
dnf_module_list: {get_param: DnfStreams}
dnf:
name: "@{{ item.module }}:{{ item.stream }}/{{ item.profile|default('common') }}"
state: present
loop: "{{ dnf_module_list|list }}"
when:
- ansible_distribution_major_version >= '8'
- dnf_module_list|length > 0
- name: Ensure TripleO prerequisite packages are installed
package:
name:
@ -314,6 +331,17 @@ outputs:
- step|int == 0
- ansible_distribution == 'RedHat'
- not (skip_rhel_enforcement | bool)
- name: Ensure DNF modules have the right stream
vars:
dnf_module_list: {get_param: DnfStreams}
dnf:
name: "@{{ item.module }}:{{ item.stream }}/{{ item.profile|default('common') }}"
state: present
loop: "{{ dnf_module_list|list }}"
when:
- step|int == 0
- ansible_distribution_major_version >= '8'
- dnf_module_list|length > 0
- name: Check for existing yum.pid
stat: path=/run/yum.pid
register: yum_pid_file

View File

@ -36,6 +36,13 @@ parameters:
Mainly for CI purpose. It shouldn't matter on other distributions
where it's disabled in the role. Set to true to skip the enforcement.
type: string
DnfStreams:
default: []
description: List of streams to be configured before updating packages. Each list
element contains a dictionary with the following values defined
module[mandatory], stream[mandatory] and profile[optional]. If the profile
is not specified 'common' will be used instead.
type: json
outputs:
role_data:
@ -60,6 +67,17 @@ outputs:
- step|int == 0
- ansible_distribution == 'RedHat'
- not (skip_rhel_enforcement | bool)
- name: Ensure DNF modules have the right stream
vars:
dnf_module_list: {get_param: DnfStreams}
dnf:
name: "@{{ item.module }}:{{ item.stream }}/{{ item.profile|default('common') }}"
state: present
loop: "{{ dnf_module_list|list }}"
when:
- step|int == 0
- ansible_distribution_major_version >= '8'
- dnf_module_list|length > 0
- name: Special treatment for OpenvSwitch
tripleo_ovs_upgrade:
when:

View File

@ -6,3 +6,4 @@ resource_registry:
parameter_defaults:
UndercloudUpgrade: true
DnfStreams: [{'module':'container-tools', 'stream':'2.0'}]

View File

@ -7,3 +7,4 @@ resource_registry:
parameter_defaults:
CephAnsiblePlaybook: default
DnfStreams: [{'module':'container-tools', 'stream':'2.0'}]

View File

@ -17,3 +17,4 @@ parameter_defaults:
UpgradeInitCommonCommand: |
#!/bin/bash
set -eu
DnfStreams: [{'module':'container-tools', 'stream':'2.0'}]