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

This commit is contained in:
Toshio Kuratomi 2016-03-04 09:42:38 -08:00
parent 4f97bb0491
commit 9835b6a477

View file

@ -129,7 +129,7 @@ def _fail_if_no_dnf(module):
"""Fail if unable to import dnf."""
if not HAS_DNF:
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):
@ -176,7 +176,6 @@ def _specify_repositories(base, disablerepo, enablerepo):
def _base(module, conf_file, disable_gpg_check, disablerepo, enablerepo):
"""Return a fully configured dnf Base object."""
_fail_if_no_dnf(module)
base = dnf.Base()
_configure_base(module, base, conf_file, disable_gpg_check)
_specify_repositories(base, disablerepo, enablerepo)
@ -331,6 +330,8 @@ def main():
mutually_exclusive=[['name', 'list']],
supports_check_mode=True)
params = module.params
_fail_if_no_dnf(module)
if params['list']:
base = _base(
module, params['conf_file'], params['disable_gpg_check'],