mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
dnf - fix conf_file loading (#50515)
This commit is contained in:
parent
d21ed42f4b
commit
63e454a4b2
3 changed files with 44 additions and 43 deletions
|
@ -497,6 +497,17 @@ class DnfModule(YumDnf):
|
|||
|
||||
conf = base.conf
|
||||
|
||||
# Change the configuration file path if provided, this must be done before conf.read() is called
|
||||
if conf_file:
|
||||
# Fail if we can't read the configuration file.
|
||||
if not os.access(conf_file, os.R_OK):
|
||||
self.module.fail_json(
|
||||
msg="cannot read configuration file", conf_file=conf_file,
|
||||
results=[],
|
||||
)
|
||||
else:
|
||||
conf.config_file_path = conf_file
|
||||
|
||||
# Read the configuration file
|
||||
conf.read()
|
||||
|
||||
|
@ -545,17 +556,6 @@ class DnfModule(YumDnf):
|
|||
if self.download_only:
|
||||
conf.downloadonly = True
|
||||
|
||||
# Change the configuration file path if provided
|
||||
if conf_file:
|
||||
# Fail if we can't read the configuration file.
|
||||
if not os.access(conf_file, os.R_OK):
|
||||
self.module.fail_json(
|
||||
msg="cannot read configuration file", conf_file=conf_file,
|
||||
results=[],
|
||||
)
|
||||
else:
|
||||
conf.config_file_path = conf_file
|
||||
|
||||
# Default in dnf upstream is true
|
||||
conf.clean_requirements_on_remove = self.autoremove
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue