diff options
| author | Toshio Kuratomi <a.badger@gmail.com> | 2015-11-02 08:02:52 -0800 |
|---|---|---|
| committer | Toshio Kuratomi <a.badger@gmail.com> | 2015-11-02 08:02:52 -0800 |
| commit | 08986221cb36feb468ea1e8c5420a64ac36f11cf (patch) | |
| tree | a91155bd5e157e108f365d1efc6ed6a1ae3cf995 | |
| parent | 257696c0ed4e9f0c890ee83b0bbf4a9562d230ed (diff) | |
| parent | 0b9e9fd852db09091793adf9167a29adb2addaf0 (diff) | |
| download | ansible-modules-extras-08986221cb36feb468ea1e8c5420a64ac36f11cf.tar.gz | |
Merge pull request #1189 from ansible/dnf-hang
The dnf API appears to hang if the user does not have adequate permissions
| -rw-r--r-- | packaging/os/dnf.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/packaging/os/dnf.py b/packaging/os/dnf.py index 58cf4bca..50c86fc4 100644 --- a/packaging/os/dnf.py +++ b/packaging/os/dnf.py @@ -234,9 +234,6 @@ def _mark_package_install(module, base, pkg_spec): def ensure(module, base, state, names): - if not util.am_i_root(): - module.fail_json(msg="This command has to be run under the root user.") - if names == ['*'] and state == 'latest': base.upgrade_all() else: @@ -330,12 +327,20 @@ def main(): mutually_exclusive=[['name', 'list']], supports_check_mode=True) params = module.params - base = _base( - module, params['conf_file'], params['disable_gpg_check'], - params['disablerepo'], params['enablerepo']) if params['list']: + base = _base( + module, params['conf_file'], params['disable_gpg_check'], + params['disablerepo'], params['enablerepo']) list_items(module, base, params['list']) else: + # Note: base takes a long time to run so we want to check for failure + # before running it. + if not util.am_i_root(): + module.fail_json(msg="This command has to be run under the root user.") + base = _base( + module, params['conf_file'], params['disable_gpg_check'], + params['disablerepo'], params['enablerepo']) + ensure(module, base, params['state'], params['name']) |
