mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Provide a better error when python-dnf install fails (#57622)
This commit is contained in:
parent
2575f0e39b
commit
c3ca3757c9
2 changed files with 12 additions and 3 deletions
2
changelogs/fragments/dnf-better-error.yml
Normal file
2
changelogs/fragments/dnf-better-error.yml
Normal file
|
@ -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 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='/'):
|
||||
|
|
Loading…
Reference in a new issue