From c602d49d421ab7e75bf67a60ef588aa316ce8e0d Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Fri, 4 Mar 2016 09:42:38 -0800 Subject: [PATCH] Fail due to no dnf module installed earlier as we use a dnf utility function to determine if we have permission to install packages. --- lib/ansible/modules/extras/packaging/os/dnf.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/extras/packaging/os/dnf.py b/lib/ansible/modules/extras/packaging/os/dnf.py index dfb733b2a96..7d432186a6e 100644 --- a/lib/ansible/modules/extras/packaging/os/dnf.py +++ b/lib/ansible/modules/extras/packaging/os/dnf.py @@ -136,7 +136,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): @@ -183,7 +183,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) @@ -338,6 +337,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'],