Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dnf module load/init dnf pkg mgr plugins properly #49278

Merged
merged 2 commits into from
Nov 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelogs/fragments/dnf-fix-plugin-loading.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
minor_changes:
- "dnf module properly load and initialize dnf package manager plugins"
19 changes: 9 additions & 10 deletions lib/ansible/modules/packaging/os/dnf.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,15 +495,11 @@ def _ensure_dnf(self):
def _configure_base(self, base, conf_file, disable_gpg_check, installroot='/'):
"""Configure the dnf Base object."""

if self.enable_plugin and self.disable_plugin:
base.init_plugins(self.disable_plugin, self.enable_plugin)
elif self.enable_plugin:
base.init_plugins(enable_plugins=self.enable_plugin)
elif self.disable_plugin:
base.init_plugins(self.disable_plugin)

conf = base.conf

# Read the configuration file
conf.read()

# Turn off debug messages in the output
conf.debuglevel = 0

Expand Down Expand Up @@ -563,9 +559,6 @@ def _configure_base(self, base, conf_file, disable_gpg_check, installroot='/'):
# Default in dnf upstream is true
conf.clean_requirements_on_remove = self.autoremove

# Read the configuration file
conf.read()

def _specify_repositories(self, base, disablerepo, enablerepo):
"""Enable and disable repositories matching the provided patterns."""
base.read_all_repos()
Expand All @@ -588,6 +581,12 @@ def _base(self, conf_file, disable_gpg_check, disablerepo, enablerepo, installro
base = dnf.Base()
self._configure_base(base, conf_file, disable_gpg_check, installroot)
self._specify_repositories(base, disablerepo, enablerepo)
try:
base.init_plugins(set(self.disable_plugin), set(self.enable_plugin))
base.pre_configure_plugins()
base.configure_plugins()
except AttributeError:
pass # older versions of dnf didn't require this and don't have these methods
try:
base.fill_sack(load_system_repo='auto')
except dnf.exceptions.RepoError as e:
Expand Down