From f89e5315afed6edf07f62fdb6e7b6a64e0055aee Mon Sep 17 00:00:00 2001 From: James Tanner Date: Thu, 27 Feb 2014 12:18:25 -0500 Subject: [PATCH 1/7] Add install_repoquery parameter to the yum module --- library/packaging/yum | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/library/packaging/yum b/library/packaging/yum index 11d9bfcc3e..f3b115c28c 100644 --- a/library/packaging/yum +++ b/library/packaging/yum @@ -94,6 +94,16 @@ options: default: "no" choices: ["yes", "no"] aliases: [] + + install_repoquery: + description: + - If repoquery is not available, install yum-utils + required: false + version_added: "1.5" + default: no + choices: ["yes", "no"] + aliaes: [] + notes: [] # informational: requirements for nodes requirements: [ yum, rpm ] @@ -154,6 +164,17 @@ def yum_base(conf_file=None, cachedir=False): return my +def install_yum_utils(module): + + if not module.check_mode: + yum_path = module.get_bin_path('yum') + if yum_path: + rc, so, se = module.run_command('%s -y install yum-utils' % yum_path) + if rc == 0: + this_path = module.get_bin_path('repoquery') + global repoquery + repoquery = this_path + def po_to_nevra(po): if hasattr(po, 'ui_nevra'): @@ -789,6 +810,7 @@ def main(): list=dict(), conf_file=dict(default=None), disable_gpg_check=dict(required=False, default="no", type='bool'), + install_repoquery=dict(required=False, default="no", type='bool'), ), required_one_of = [['name','list']], mutually_exclusive = [['name','list']], @@ -797,6 +819,9 @@ def main(): params = module.params + if params.install_repoquery and not repoquery and not module.check_mode: + install_yum_utils(module) + if params['list']: if not repoquery: module.fail_json(msg="repoquery is required to use list= with this module. Please install the yum-utils package.") From 79fb252dc9c8752e96fa5ae32ccec5a89a26de7a Mon Sep 17 00:00:00 2001 From: James Tanner Date: Thu, 27 Feb 2014 12:34:53 -0500 Subject: [PATCH 2/7] Update docstring for rhn details --- library/packaging/yum | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/library/packaging/yum b/library/packaging/yum index f3b115c28c..4573fa5ed7 100644 --- a/library/packaging/yum +++ b/library/packaging/yum @@ -97,7 +97,9 @@ options: install_repoquery: description: - - If repoquery is not available, install yum-utils + - If repoquery is not available, install yum-utils. If the system is + registered to RHN or an RHN Satellite, repoquery allows for querying + all channels assigned to the system. required: false version_added: "1.5" default: no From da210522f3fb8992f198590c9e730a19f3641ce7 Mon Sep 17 00:00:00 2001 From: James Tanner Date: Thu, 27 Feb 2014 12:39:27 -0500 Subject: [PATCH 3/7] Fix up docstring type and extra info about list --- library/packaging/yum | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/library/packaging/yum b/library/packaging/yum index 4573fa5ed7..065f44e229 100644 --- a/library/packaging/yum +++ b/library/packaging/yum @@ -99,12 +99,13 @@ options: description: - If repoquery is not available, install yum-utils. If the system is registered to RHN or an RHN Satellite, repoquery allows for querying - all channels assigned to the system. + all channels assigned to the system. repoquery is also requires to + use the "list" parameter. required: false version_added: "1.5" default: no choices: ["yes", "no"] - aliaes: [] + aliases: [] notes: [] # informational: requirements for nodes From 58c78539bb66543821068054da884ab472f41c3f Mon Sep 17 00:00:00 2001 From: James Tanner Date: Thu, 27 Feb 2014 12:40:51 -0500 Subject: [PATCH 4/7] Fix typo --- library/packaging/yum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/packaging/yum b/library/packaging/yum index 065f44e229..78cd105f82 100644 --- a/library/packaging/yum +++ b/library/packaging/yum @@ -99,7 +99,7 @@ options: description: - If repoquery is not available, install yum-utils. If the system is registered to RHN or an RHN Satellite, repoquery allows for querying - all channels assigned to the system. repoquery is also requires to + all channels assigned to the system. repoquery is also required to use the "list" parameter. required: false version_added: "1.5" From 3f43fa529d9f37211472d307c6a3a6e5ab667886 Mon Sep 17 00:00:00 2001 From: James Tanner Date: Thu, 27 Feb 2014 13:16:30 -0500 Subject: [PATCH 5/7] Install yum-utils by default --- library/packaging/yum | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/packaging/yum b/library/packaging/yum index 78cd105f82..fbca078bff 100644 --- a/library/packaging/yum +++ b/library/packaging/yum @@ -103,7 +103,7 @@ options: use the "list" parameter. required: false version_added: "1.5" - default: no + default: "yes" choices: ["yes", "no"] aliases: [] @@ -813,7 +813,7 @@ def main(): list=dict(), conf_file=dict(default=None), disable_gpg_check=dict(required=False, default="no", type='bool'), - install_repoquery=dict(required=False, default="no", type='bool'), + install_repoquery=dict(required=False, default="yes", type='bool'), ), required_one_of = [['name','list']], mutually_exclusive = [['name','list']], From 122a7021bc0af079bc065e0314828fdcfd112f44 Mon Sep 17 00:00:00 2001 From: James Tanner Date: Thu, 27 Feb 2014 13:29:15 -0500 Subject: [PATCH 6/7] remove install_repoquery docstring --- library/packaging/yum | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/library/packaging/yum b/library/packaging/yum index fbca078bff..211ae7cf8a 100644 --- a/library/packaging/yum +++ b/library/packaging/yum @@ -95,18 +95,6 @@ options: choices: ["yes", "no"] aliases: [] - install_repoquery: - description: - - If repoquery is not available, install yum-utils. If the system is - registered to RHN or an RHN Satellite, repoquery allows for querying - all channels assigned to the system. repoquery is also required to - use the "list" parameter. - required: false - version_added: "1.5" - default: "yes" - choices: ["yes", "no"] - aliases: [] - notes: [] # informational: requirements for nodes requirements: [ yum, rpm ] From aeccbeeed2c3328ea991dca8405840f4fc706ed0 Mon Sep 17 00:00:00 2001 From: James Tanner Date: Thu, 27 Feb 2014 13:42:05 -0500 Subject: [PATCH 7/7] add failsafe comment for install_repoquery --- library/packaging/yum | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/library/packaging/yum b/library/packaging/yum index 211ae7cf8a..61bb836b43 100644 --- a/library/packaging/yum +++ b/library/packaging/yum @@ -801,6 +801,7 @@ def main(): list=dict(), conf_file=dict(default=None), disable_gpg_check=dict(required=False, default="no", type='bool'), + # this should not be needed, but exists as a failsafe install_repoquery=dict(required=False, default="yes", type='bool'), ), required_one_of = [['name','list']], @@ -808,9 +809,9 @@ def main(): supports_check_mode = True ) + # this should not be needed, but exists as a failsafe params = module.params - - if params.install_repoquery and not repoquery and not module.check_mode: + if params['install_repoquery'] and not repoquery and not module.check_mode: install_yum_utils(module) if params['list']: