Fail due to no dnf module installed earlier as we use a dnf utility function to determine if we have permission to install packages.

pull/18777/head
Toshio Kuratomi 9 years ago committed by Matt Clay
parent bb194b03bc
commit c602d49d42

@ -136,7 +136,7 @@ def _fail_if_no_dnf(module):
"""Fail if unable to import dnf.""" """Fail if unable to import dnf."""
if not HAS_DNF: if not HAS_DNF:
module.fail_json( module.fail_json(
msg="`python-dnf` is not installed, but it is required for the Ansible dnf module.") msg="`python2-dnf` is not installed, but it is required for the Ansible dnf module.")
def _configure_base(module, base, conf_file, disable_gpg_check): def _configure_base(module, base, conf_file, disable_gpg_check):
@ -183,7 +183,6 @@ def _specify_repositories(base, disablerepo, enablerepo):
def _base(module, conf_file, disable_gpg_check, disablerepo, enablerepo): def _base(module, conf_file, disable_gpg_check, disablerepo, enablerepo):
"""Return a fully configured dnf Base object.""" """Return a fully configured dnf Base object."""
_fail_if_no_dnf(module)
base = dnf.Base() base = dnf.Base()
_configure_base(module, base, conf_file, disable_gpg_check) _configure_base(module, base, conf_file, disable_gpg_check)
_specify_repositories(base, disablerepo, enablerepo) _specify_repositories(base, disablerepo, enablerepo)
@ -338,6 +337,8 @@ def main():
mutually_exclusive=[['name', 'list']], mutually_exclusive=[['name', 'list']],
supports_check_mode=True) supports_check_mode=True)
params = module.params params = module.params
_fail_if_no_dnf(module)
if params['list']: if params['list']:
base = _base( base = _base(
module, params['conf_file'], params['disable_gpg_check'], module, params['conf_file'], params['disable_gpg_check'],

Loading…
Cancel
Save