From 5e94e1ad5d0eba9acf28f507cbacb1ef929ca297 Mon Sep 17 00:00:00 2001 From: Alfredo Moralejo Date: Thu, 16 Apr 2020 11:23:50 +0200 Subject: [PATCH] Fix manage_rdo function for CentOS8 In CentOS 8 the rdo-release package uses %dist in the name, which is currently breaking the regular expresion used to parse it. Also, in CentOS 8, yum-config-manager is not providing the full repo configuration by stdout when enabling a repo, so instead of parsing it, let's just trust on standard return value from command which works as expected. For CentOS 7 we need to keep the same behavior. This patch is fixing it to work with both centos7 and 8 Change-Id: Iafd6d6373d608c1b0fb797895a9969da28049fec --- packstack/plugins/prescript_000.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/packstack/plugins/prescript_000.py b/packstack/plugins/prescript_000.py index ef28400b5..5179509d5 100755 --- a/packstack/plugins/prescript_000.py +++ b/packstack/plugins/prescript_000.py @@ -1133,10 +1133,14 @@ def manage_rdo(host, config): # RDO repo is not installed, so we don't need to continue return - match = re.match(r'^(?P\w+)\-(?P\d+\.[\d\w]+)\n', out) - version, release = match.group('version'), match.group('release') + match = re.match(r'^(?P\w+)\-.*\n', out) + version = match.group('version') + if re.match(r'^(.*\.el8.*\n)', out): + dist_tag = '.el8' + else: + dist_tag = '' rdo_url = ("https://www.rdoproject.org/repos/openstack-%(version)s/" - "rdo-release-%(version)s.rpm" % locals()) + "rdo-release-%(version)s%(dist_tag)s.rpm" % locals()) server = utils.ScriptRunner(host) server.append("(rpm -q 'rdo-release-%(version)s' ||" @@ -1156,12 +1160,13 @@ def manage_rdo(host, config): server.append('yum-config-manager --disable %(reponame)s' % locals()) server.append('yum-config-manager --enable %(reponame)s-testing' % locals()) - # yum-config-manager returns 0 always, but returns current setup - # if succeeds rc, out = server.execute() - match = re.search('enabled\s*=\s*(1|True)', out) - if not match: + # In CentOS 7 yum-config-manager returns 0 always, but returns current setup + # if succeeds + # In CentOS 8 yum-config-manager returns 1 when failing but doesn't return current + # setup if succeeds + if (dist_tag == '.el8' and rc != 0) or (dist_tag == '' and not match): msg = ('Failed to set RDO repo on host %s:\nRPM file seems to be ' 'installed, but appropriate repo file is probably missing ' 'in /etc/yum.repos.d/' % host)