summaryrefslogtreecommitdiffstats
path: root/lib/ansible/modules
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-25 02:51:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-25 02:51:09 +0000
commit0832b2cf4b69cd84a24139132ccbc4b1d38cef42 (patch)
tree4c8ab9c23dbf2aebe016922303390be7eca71df4 /lib/ansible/modules
parentAdding upstream version 2.16.5. (diff)
downloadansible-core-0832b2cf4b69cd84a24139132ccbc4b1d38cef42.tar.xz
ansible-core-0832b2cf4b69cd84a24139132ccbc4b1d38cef42.zip
Adding upstream version 2.16.6.upstream/2.16.6
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'lib/ansible/modules')
-rw-r--r--lib/ansible/modules/blockinfile.py2
-rw-r--r--lib/ansible/modules/dnf.py6
-rw-r--r--lib/ansible/modules/dnf5.py17
-rw-r--r--lib/ansible/modules/find.py11
-rw-r--r--lib/ansible/modules/unarchive.py2
5 files changed, 26 insertions, 12 deletions
diff --git a/lib/ansible/modules/blockinfile.py b/lib/ansible/modules/blockinfile.py
index 8c83bf0..3ede6fd 100644
--- a/lib/ansible/modules/blockinfile.py
+++ b/lib/ansible/modules/blockinfile.py
@@ -269,7 +269,7 @@ def main():
module.fail_json(rc=257,
msg='Path %s does not exist !' % path)
destpath = os.path.dirname(path)
- if not os.path.exists(destpath) and not module.check_mode:
+ if destpath and not os.path.exists(destpath) and not module.check_mode:
try:
os.makedirs(destpath)
except OSError as e:
diff --git a/lib/ansible/modules/dnf.py b/lib/ansible/modules/dnf.py
index 7f5afc3..50d0ca6 100644
--- a/lib/ansible/modules/dnf.py
+++ b/lib/ansible/modules/dnf.py
@@ -1441,8 +1441,10 @@ class DnfModule(YumDnf):
if self.with_modules:
self.module_base = dnf.module.module_base.ModuleBase(self.base)
-
- self.ensure()
+ try:
+ self.ensure()
+ finally:
+ self.base.close()
def main():
diff --git a/lib/ansible/modules/dnf5.py b/lib/ansible/modules/dnf5.py
index 823d3a7..c55b673 100644
--- a/lib/ansible/modules/dnf5.py
+++ b/lib/ansible/modules/dnf5.py
@@ -484,7 +484,7 @@ class Dnf5Module(YumDnf):
conf.config_file_path = self.conf_file
try:
- base.load_config_from_file()
+ base.load_config()
except RuntimeError as e:
self.module.fail_json(
msg=str(e),
@@ -520,7 +520,8 @@ class Dnf5Module(YumDnf):
log_router = base.get_logger()
global_logger = libdnf5.logger.GlobalLogger()
global_logger.set(log_router.get(), libdnf5.logger.Logger.Level_DEBUG)
- logger = libdnf5.logger.create_file_logger(base)
+ # FIXME hardcoding the filename does not seem right, should libdnf5 expose the default file name?
+ logger = libdnf5.logger.create_file_logger(base, "dnf5.log")
log_router.add_logger(logger)
if self.update_cache:
@@ -545,7 +546,11 @@ class Dnf5Module(YumDnf):
for repo in repo_query:
repo.enable()
- sack.update_and_load_enabled_repos(True)
+ try:
+ sack.load_repos()
+ except AttributeError:
+ # dnf5 < 5.2.0.0
+ sack.update_and_load_enabled_repos(True)
if self.update_cache and not self.names and not self.list:
self.module.exit_json(
@@ -577,7 +582,11 @@ class Dnf5Module(YumDnf):
self.module.exit_json(msg="", results=results, rc=0)
settings = libdnf5.base.GoalJobSettings()
- settings.group_with_name = True
+ try:
+ settings.set_group_with_name(True)
+ except AttributeError:
+ # dnf5 < 5.2.0.0
+ settings.group_with_name = True
if self.bugfix or self.security:
advisory_query = libdnf5.advisory.AdvisoryQuery(base)
types = []
diff --git a/lib/ansible/modules/find.py b/lib/ansible/modules/find.py
index d2e6c8b..0251224 100644
--- a/lib/ansible/modules/find.py
+++ b/lib/ansible/modules/find.py
@@ -258,6 +258,7 @@ skipped_paths:
version_added: '2.12'
'''
+import errno
import fnmatch
import grp
import os
@@ -434,10 +435,6 @@ def statinfo(st):
}
-def handle_walk_errors(e):
- raise e
-
-
def main():
module = AnsibleModule(
argument_spec=dict(
@@ -482,6 +479,12 @@ def main():
filelist = []
skipped = {}
+ def handle_walk_errors(e):
+ if e.errno in (errno.EPERM, errno.EACCES):
+ skipped[e.filename] = to_text(e)
+ return
+ raise e
+
if params['age'] is None:
age = None
else:
diff --git a/lib/ansible/modules/unarchive.py b/lib/ansible/modules/unarchive.py
index ec15a57..b3e8058 100644
--- a/lib/ansible/modules/unarchive.py
+++ b/lib/ansible/modules/unarchive.py
@@ -969,7 +969,7 @@ class TarZstdArchive(TgzArchive):
class ZipZArchive(ZipArchive):
def __init__(self, src, b_dest, file_args, module):
super(ZipZArchive, self).__init__(src, b_dest, file_args, module)
- self.zipinfoflag = '-Z'
+ self.zipinfoflag = '-Zl'
self.binaries = (
('unzip', 'cmd_path'),
('unzip', 'zipinfo_cmd_path'),