Provide a better error when python-dnf install fails (#57622)

This commit is contained in:
Matt Martz 2019-06-10 09:21:42 -05:00 committed by Adam Miller
parent 2575f0e39b
commit c3ca3757c9
2 changed files with 12 additions and 3 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- dnf - Provide a better error message including python version info when installing python-dnf fails

View file

@ -285,6 +285,7 @@ EXAMPLES = '''
import os
import re
import sys
import tempfile
try:
@ -488,7 +489,7 @@ class DnfModule(YumDnf):
results=[],
)
self.module.run_command(['dnf', 'install', '-y', package], check_rc=True)
rc, stdout, stderr = self.module.run_command(['dnf', 'install', '-y', package])
global dnf
try:
import dnf
@ -499,9 +500,15 @@ class DnfModule(YumDnf):
import dnf.util
except ImportError:
self.module.fail_json(
msg="Could not import the dnf python module. "
"Please install `{0}` package.".format(package),
msg="Could not import the dnf python module using {0} ({1}). "
"Please install `{2}` package or ensure you have specified the "
"correct ansible_python_interpreter.".format(sys.executable, sys.version.replace('\n', ''),
package),
results=[],
cmd='dnf install -y {0}'.format(package),
rc=rc,
stdout=stdout,
stderr=stderr,
)
def _configure_base(self, base, conf_file, disable_gpg_check, installroot='/'):