Bandaid dnf module to temporarily fix some major problems
- Backport config file handling from the DNF module rewrite #527 (Current config handling does not work with dnf and leads to tracebacks when run as an unprivileged user). - Make a mandatory requirement on yum-utils (for /usr/bin/repoquery) because none of the fallback code works for dnf (it's unported yum API code). Both of these issues will be fixed better in the dnf rewrite when it is feature complete. Fixes #471
This commit is contained in:
parent
8dfa63d1d8
commit
a1a1c23205
1 changed files with 11 additions and 15 deletions
|
@ -92,7 +92,9 @@ options:
|
||||||
|
|
||||||
notes: []
|
notes: []
|
||||||
# informational: requirements for nodes
|
# informational: requirements for nodes
|
||||||
requirements: [ dnf ]
|
requirements:
|
||||||
|
- dnf
|
||||||
|
- yum-utils (for repoquery)
|
||||||
author: '"Cristian van Ee (@DJMuggs)" <cristian at cvee.org>'
|
author: '"Cristian van Ee (@DJMuggs)" <cristian at cvee.org>'
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
@ -137,18 +139,12 @@ def log(msg):
|
||||||
def dnf_base(conf_file=None, cachedir=False):
|
def dnf_base(conf_file=None, cachedir=False):
|
||||||
|
|
||||||
my = dnf.Base()
|
my = dnf.Base()
|
||||||
my.logging.verbose_level=0
|
my.conf.debuglevel=0
|
||||||
my.logging.verbose_level=0
|
|
||||||
if conf_file and os.path.exists(conf_file):
|
if conf_file and os.path.exists(conf_file):
|
||||||
my.config = conf_file
|
my.conf.config_file_path = conf_file
|
||||||
if cachedir or os.geteuid() != 0:
|
my.conf.read()
|
||||||
if cachedir or os.geteuid() != 0:
|
my.read_all_repos()
|
||||||
if hasattr(my, 'setCacheDir'):
|
my.fill_sack()
|
||||||
my.setCacheDir()
|
|
||||||
else:
|
|
||||||
cachedir = cachedir.dnf.Conf()
|
|
||||||
my.repos.setCacheDir(cachedir)
|
|
||||||
my.conf.cache = 0
|
|
||||||
|
|
||||||
return my
|
return my
|
||||||
|
|
||||||
|
@ -157,7 +153,7 @@ def install_dnf_utils(module):
|
||||||
if not module.check_mode:
|
if not module.check_mode:
|
||||||
dnf_path = module.get_bin_path('dnf')
|
dnf_path = module.get_bin_path('dnf')
|
||||||
if dnf_path:
|
if dnf_path:
|
||||||
rc, so, se = module.run_command('%s -y install dnf-plugins-core' % dnf_path)
|
rc, so, se = module.run_command('%s -y install yum-utils' % dnf_path)
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
this_path = module.get_bin_path('repoquery')
|
this_path = module.get_bin_path('repoquery')
|
||||||
global repoquery
|
global repoquery
|
||||||
|
@ -812,9 +808,9 @@ def main():
|
||||||
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_dnf_utils(module)
|
install_dnf_utils(module)
|
||||||
|
|
||||||
|
if not repoquery:
|
||||||
|
module.fail_json(msg="repoquery is required to use this module at this time. Please install the yum-utils package.")
|
||||||
if params['list']:
|
if params['list']:
|
||||||
if not repoquery:
|
|
||||||
module.fail_json(msg="repoquery is required to use list= with this module. Please install the dnf-utils package.")
|
|
||||||
results = dict(results=list_stuff(module, params['conf_file'], params['list']))
|
results = dict(results=list_stuff(module, params['conf_file'], params['list']))
|
||||||
module.exit_json(**results)
|
module.exit_json(**results)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue