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)