yaml cache plugin: make compatible with ansible-core 2.19 (#10852)
Some checks are pending
EOL CI / EOL Sanity (Ⓐ2.16) (push) Waiting to run
EOL CI / EOL Units (Ⓐ2.16+py2.7) (push) Waiting to run
EOL CI / EOL Units (Ⓐ2.16+py3.11) (push) Waiting to run
EOL CI / EOL Units (Ⓐ2.16+py3.6) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.16+alpine3+py:azp/posix/1/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.16+alpine3+py:azp/posix/2/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.16+alpine3+py:azp/posix/3/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.16+fedora38+py:azp/posix/1/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.16+fedora38+py:azp/posix/2/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.16+fedora38+py:azp/posix/3/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.16+opensuse15+py:azp/posix/1/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.16+opensuse15+py:azp/posix/2/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.16+opensuse15+py:azp/posix/3/) (push) Waiting to run
nox / Run extra sanity tests (push) Waiting to run

Make compatible with ansible-core 2.19.
This commit is contained in:
Felix Fontein 2025-09-25 06:57:37 +02:00 committed by GitHub
commit 648ff7db02
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 4 deletions

View file

@ -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)."

View file

@ -44,8 +44,7 @@ options:
# TODO: determine whether it is OK to change to: type: float # TODO: determine whether it is OK to change to: type: float
""" """
import os
import codecs
import yaml import yaml
@ -60,9 +59,9 @@ class CacheModule(BaseFileCacheModule):
""" """
def _load(self, filepath): 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() return AnsibleLoader(f).get_single_data()
def _dump(self, value, filepath): 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) yaml.dump(value, f, Dumper=AnsibleDumper, default_flow_style=False)