From 89e0d070715661204beb45be349b0a40cb1f5620 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Sat, 2 May 2026 10:35:08 +1200 Subject: [PATCH] puppet: fix `TypeError` when writing facts data (#11954) * fix(puppet): remove erroneous encode() call in _write_structured_data() Fixes #7932 * changelog: add fragment for puppet facts TypeError fix (#11954) --- changelogs/fragments/11954-puppet-facts-write-error.yml | 2 ++ plugins/modules/puppet.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/11954-puppet-facts-write-error.yml diff --git a/changelogs/fragments/11954-puppet-facts-write-error.yml b/changelogs/fragments/11954-puppet-facts-write-error.yml new file mode 100644 index 0000000000..992ec409ad --- /dev/null +++ b/changelogs/fragments/11954-puppet-facts-write-error.yml @@ -0,0 +1,2 @@ +bugfixes: + - puppet - fix ``TypeError`` when writing facts data (https://github.com/ansible-collections/community.general/issues/7932, https://github.com/ansible-collections/community.general/pull/11954). diff --git a/plugins/modules/puppet.py b/plugins/modules/puppet.py index 36c3371541..b0d46db12e 100644 --- a/plugins/modules/puppet.py +++ b/plugins/modules/puppet.py @@ -204,7 +204,7 @@ def _write_structured_data(basedir, basename, data): # open the file with only u+rw set. Also, we use the stat constants # because ansible still supports python 2.4 and the octal syntax changed out_file = os.fdopen(os.open(file_path, os.O_CREAT | os.O_WRONLY, stat.S_IRUSR | stat.S_IWUSR), "w") - out_file.write(json.dumps(data).encode("utf8")) + out_file.write(json.dumps(data)) out_file.close()