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

pull/57640/head
Matt Martz 6 years ago committed by Adam Miller
parent 2575f0e39b
commit c3ca3757c9

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

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

Loading…
Cancel
Save