1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Set disabled repos before enabled repos

The ordering of disabling/enabling yum repositories matters, and
the yum module was mixing and matching the order. Specifically,
when yum-utils isn't installed, the codepath which uses the yum
python module was incorrectly ordering enabling and disabling.

The preferred order is to disable repositories and then enable them
to prevent clobbering. This was previously discussed in
ansible/ansible#5255 and incompletely addressed in 0cca4a3.
This commit is contained in:
David Wittman 2015-03-27 11:07:51 -05:00 committed by Matt Clay
parent 0f0cb9dc16
commit be0d28a4ac

View file

@ -187,10 +187,10 @@ def is_installed(module, repoq, pkgspec, conf_file, qf=def_qf, en_repos=[], dis_
pkgs = [] pkgs = []
try: try:
my = yum_base(conf_file) my = yum_base(conf_file)
for rid in en_repos:
my.repos.enableRepo(rid)
for rid in dis_repos: for rid in dis_repos:
my.repos.disableRepo(rid) my.repos.disableRepo(rid)
for rid in en_repos:
my.repos.enableRepo(rid)
e,m,u = my.rpmdb.matchPackageNames([pkgspec]) e,m,u = my.rpmdb.matchPackageNames([pkgspec])
pkgs = e + m pkgs = e + m
@ -226,10 +226,10 @@ def is_available(module, repoq, pkgspec, conf_file, qf=def_qf, en_repos=[], dis_
pkgs = [] pkgs = []
try: try:
my = yum_base(conf_file) my = yum_base(conf_file)
for rid in en_repos:
my.repos.enableRepo(rid)
for rid in dis_repos: for rid in dis_repos:
my.repos.disableRepo(rid) my.repos.disableRepo(rid)
for rid in en_repos:
my.repos.enableRepo(rid)
e,m,u = my.pkgSack.matchPackageNames([pkgspec]) e,m,u = my.pkgSack.matchPackageNames([pkgspec])
pkgs = e + m pkgs = e + m
@ -269,10 +269,10 @@ def is_update(module, repoq, pkgspec, conf_file, qf=def_qf, en_repos=[], dis_rep
try: try:
my = yum_base(conf_file) my = yum_base(conf_file)
for rid in en_repos:
my.repos.enableRepo(rid)
for rid in dis_repos: for rid in dis_repos:
my.repos.disableRepo(rid) my.repos.disableRepo(rid)
for rid in en_repos:
my.repos.enableRepo(rid)
pkgs = my.returnPackagesByDep(pkgspec) + my.returnInstalledPackagesByDep(pkgspec) pkgs = my.returnPackagesByDep(pkgspec) + my.returnInstalledPackagesByDep(pkgspec)
if not pkgs: if not pkgs:
@ -313,10 +313,10 @@ def what_provides(module, repoq, req_spec, conf_file, qf=def_qf, en_repos=[], d
pkgs = [] pkgs = []
try: try:
my = yum_base(conf_file) my = yum_base(conf_file)
for rid in en_repos:
my.repos.enableRepo(rid)
for rid in dis_repos: for rid in dis_repos:
my.repos.disableRepo(rid) my.repos.disableRepo(rid)
for rid in en_repos:
my.repos.enableRepo(rid)
pkgs = my.returnPackagesByDep(req_spec) + my.returnInstalledPackagesByDep(req_spec) pkgs = my.returnPackagesByDep(req_spec) + my.returnInstalledPackagesByDep(req_spec)
if not pkgs: if not pkgs: