From d0712b1ec752ec469f6ef662c05977a29e28fbf1 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Wed, 22 Mar 2017 22:38:54 -0700 Subject: [PATCH] Make yum's state=list obey disablerepo and enablerepo Fixes #22876 --- lib/ansible/modules/packaging/os/yum.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/packaging/os/yum.py b/lib/ansible/modules/packaging/os/yum.py index d40a8438d18..3aed6fa7f24 100644 --- a/lib/ansible/modules/packaging/os/yum.py +++ b/lib/ansible/modules/packaging/os/yum.py @@ -624,12 +624,16 @@ def repolist(module, repoq, qf="%{repoid}"): ret = set([ p for p in out.split('\n') if p.strip() ]) return ret -def list_stuff(module, repoquerybin, conf_file, stuff, installroot='/'): +def list_stuff(module, repoquerybin, conf_file, stuff, installroot='/', disablerepo='', enablerepo=''): qf = "%{name}|%{epoch}|%{version}|%{release}|%{arch}|%{repoid}" # is_installed goes through rpm instead of repoquery so it needs a slightly different format is_installed_qf = "%{name}|%{epoch}|%{version}|%{release}|%{arch}|installed\n" repoq = [repoquerybin, '--show-duplicates', '--plugins', '--quiet'] + if disablerepo: + repoq.extend(['--disablerepo', disablerepo]) + if enablerepo: + repoq.extend(['--enablerepo', enablerepo]) if installroot != '/': repoq.extend(['--installroot', installroot]) if conf_file and os.path.exists(conf_file): @@ -1216,7 +1220,9 @@ def main(): repoquerybin = ensure_yum_utils(module) if not repoquerybin: module.fail_json(msg="repoquery is required to use list= with this module. Please install the yum-utils package.") - results = dict(results=list_stuff(module, repoquerybin, params['conf_file'], params['list'], params['installroot'])) + results = {'results': list_stuff(module, repoquerybin, params['conf_file'], + params['list'], params['installroot'], + params['disablerepo'], params['enablerepo'])} else: # If rhn-plugin is installed and no rhn-certificate is available on