From 648ff7db02bdfdd3ed9102e8d8bca46f5ffe6ce2 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Thu, 25 Sep 2025 06:57:37 +0200 Subject: [PATCH] yaml cache plugin: make compatible with ansible-core 2.19 (#10852) Make compatible with ansible-core 2.19. --- changelogs/fragments/10852-yaml.yml | 2 ++ plugins/cache/yaml.py | 7 +++---- 2 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 changelogs/fragments/10852-yaml.yml diff --git a/changelogs/fragments/10852-yaml.yml b/changelogs/fragments/10852-yaml.yml new file mode 100644 index 0000000000..1319b94ab5 --- /dev/null +++ b/changelogs/fragments/10852-yaml.yml @@ -0,0 +1,2 @@ +bugfixes: + - "yaml cache plugin - make compatible with ansible-core 2.19 (https://github.com/ansible-collections/community.general/issues/10849, https://github.com/ansible-collections/community.general/issues/10852)." diff --git a/plugins/cache/yaml.py b/plugins/cache/yaml.py index 8bf61f6898..0b82de7015 100644 --- a/plugins/cache/yaml.py +++ b/plugins/cache/yaml.py @@ -44,8 +44,7 @@ options: # TODO: determine whether it is OK to change to: type: float """ - -import codecs +import os import yaml @@ -60,9 +59,9 @@ class CacheModule(BaseFileCacheModule): """ def _load(self, filepath): - with codecs.open(filepath, 'r', encoding='utf-8') as f: + with open(os.path.abspath(filepath), 'r', encoding='utf-8') as f: return AnsibleLoader(f).get_single_data() def _dump(self, value, filepath): - with codecs.open(filepath, 'w', encoding='utf-8') as f: + with open(os.path.abspath(filepath), 'w', encoding='utf-8') as f: yaml.dump(value, f, Dumper=AnsibleDumper, default_flow_style=False)