From 2c2951b59b6e91c8f0ea6a82c1b3a9b16e1c02f7 Mon Sep 17 00:00:00 2001 From: Marcin Juszkiewicz Date: Thu, 2 Jan 2020 09:56:10 +0100 Subject: centos: disable EPEL by default Our images use 'scsi-target-utils' from EPEL and then can be built without it. So let's disable this repository right after installing package from it. Images can enable EPEL with 'enable_extra_repos' macro. Also added 'disable_extra_repos' macro as we have some images in a need. Change-Id: Id70474e7602b531b63fdc11ae690fd9ed33def74 --- kolla/template/methods.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'kolla/template/methods.py') diff --git a/kolla/template/methods.py b/kolla/template/methods.py index c4c34125d..73e9d515a 100644 --- a/kolla/template/methods.py +++ b/kolla/template/methods.py @@ -72,7 +72,7 @@ def debian_package_install(packages, clean_package_cache=True): @contextfunction -def enable_repos(context, reponames): +def handle_repos(context, reponames, mode): """NOTE(hrw): we need to handle CentOS, Debian and Ubuntu with one macro. Repo names have to be simple names mapped to proper ones. So 'ceph' == @@ -80,6 +80,14 @@ def enable_repos(context, reponames): something else for Debian. Distro/arch are not required to have all entries - we ignore missing ones. """ + + if mode == 'enable': + rpm_switch = '--enable' + elif mode == 'disable': + rpm_switch = '--disable' + else: + raise KeyError + repofile = os.path.dirname(os.path.realpath(__file__)) + '/repos.yaml' with open(repofile, 'r') as repos_file: repo_data = {} @@ -102,10 +110,11 @@ def enable_repos(context, reponames): for repo in reponames: try: if base_package_type == 'rpm': - commands += ' --enable %s' % repo_list[repo] + commands += ' %s %s' % (rpm_switch, repo_list[repo]) elif base_package_type == 'deb': - commands += 'echo "%s" ' % repo_list[repo] - commands += '>/etc/apt/sources.list.d/%s.list && ' % repo + if mode == 'enable': + commands += 'echo "%s" ' % repo_list[repo] + commands += '>/etc/apt/sources.list.d/%s.list && ' % repo except KeyError: # NOTE(hrw): we ignore missing repositories for a given # distro/arch -- cgit v1.2.3