Merge "[ffwd3] Prevent renaming nics with specific prefix" into stable/wallaby

This commit is contained in:
Zuul 2023-06-21 08:38:38 +00:00 committed by Gerrit Code Review
commit 3c59c354f2
1 changed files with 19 additions and 0 deletions

View File

@ -112,6 +112,14 @@ parameters:
default: ''
tags:
- role_specific
NICsPrefixesToUdev:
default: []
description: |
List of NIC prefixes to hardcode into udev in order to prevent
renaming.
type: comma_delimited_list
tags:
- role_specific
UpgradeInitCommand:
type: string
description: |
@ -169,6 +177,7 @@ resources:
upgrade_leapp_to_install: UpgradeLeappToInstall
leapp_repo_init_command: LeappRepoInitCommand
leapp_init_command: LeappInitCommand
nics_prefixes_to_keep: NICsPrefixesToUdev
upgrade_leapp_modules_to_unload: LeappUnloadKernelDrivers
upgrade_leapp_actors_to_remove: LeappActorsToRemove
upgrade_init_command: UpgradeInitCommand
@ -185,6 +194,7 @@ resources:
UpgradeInitCommand: {get_param: UpgradeInitCommand}
LeappRepoInitCommand: {get_param: LeappRepoInitCommand}
LeappInitCommand: {get_param: LeappInitCommand}
NICsPrefixesToUdev: {get_param: NICsPrefixesToUdev}
BaseTripleoPackages: {get_param: BaseTripleoPackages}
outputs:
@ -333,6 +343,15 @@ outputs:
dest: /boot/grub2/grubenv
state: link
force: true
- name: Keep nics with prefix in NICsPrefixesToUdev from renaming
vars:
nics_prefixes_to_keep: {get_attr: [RoleParametersValue, value, 'nics_prefixes_to_keep']}
# (.ifname | test("^.*\\..*$") | not) removes vlan nics like ens1.1
# (.ifname | test("^.*v[0-9]*$") | not) removes virtual function nics ens1v1
# (.ifname | test("^.*_[0-9]*$") | not) also removes virtual function nics ens1_1
shell: >
ip -j link show | jq -r --arg prefix "{{ item }}" '.[] | select((.ifname | startswith($prefix)) and (.ifname | test("^.*v[0-9]*$")|not) and (.ifname | test("^.*_[0-9]*$") | not) and (.ifname | test("^.*\\..*$") | not)) | "SUBSYSTEM==\"net\",ACTION==\"add\",DRIVERS==\"?*\"," + "NAME=\"" + .ifname +"\" ,ATTR{address}==\"" + .address + "\""' >> /etc/udev/rules.d/70-rhosp-persistent-net.rules
loop: "{{ nics_prefixes_to_keep|list }}"
- name: run leapp upgrade (download packages)
shell: >
{% if upgrade_leapp_devel_skip|default(false) %}{{ upgrade_leapp_devel_skip }}{% endif %}