Description
A file under ext_pillar/file_tree e.g. an openssh host key, works fine in a standard minion setup but results in Object of type bytes is not JSON serializable when using it via salt-ssh. Debugging with jeanluc on Discord showed that a small patch
diff --git i/salt/pillar/file_tree.py w/salt/pillar/file_tree.py
index f17c6ead69..0935bca139 100644
--- i/salt/pillar/file_tree.py
+++ w/salt/pillar/file_tree.py
@@ -256,6 +256,9 @@ def _construct_pillar(
if salt.utils.stringio.is_readable(data):
pillar_node[file_name] = data.getvalue()
else:
- pillar_node[file_name] = data
+ try:
+ pillar_node[file_name] = data.decode("utf-8")
+ except (AttributeError, UnicodeDecodeError):
+ pillar_node[file_name] = data
return pillar
fixes this issue
Setup
Please be as specific as possible and give set-up details.
Steps to Reproduce the behavior
Easy to reproduce with (soon to be) attached MVE file in Debian 12 VM based on Debian's cloud image.
Example state file failing is
/etc/ssh/ssh_host_ed25519_key:
file.managed:
- mode: '0600'
- contents_pillar: ssh:ssh_host_ed25519_key
with
ext_pillar:
- file_tree:
root_dir: /srv/salt/file_tree
keep_newline: True
template: False
Expected behavior
Data should be properly serialized and transferred via ssh tunnel to client
Screenshots
n/a
Versions Report
salt --versions-report
(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)
```
Salt Version:
Salt: 3007.1
Python Version:
Python: 3.10.14 (main, Apr 3 2024, 21:30:09) [GCC 11.2.0]
Dependency Versions:
cffi: 1.16.0
cherrypy: unknown
dateutil: 2.8.2
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
Jinja2: 3.1.4
libgit2: Not Installed
looseversion: 1.3.0
M2Crypto: Not Installed
Mako: Not Installed
msgpack: 1.0.7
msgpack-pure: Not Installed
mysql-python: Not Installed
packaging: 23.1
pycparser: 2.21
pycrypto: Not Installed
pycryptodome: 3.19.1
pygit2: Not Installed
python-gnupg: 0.5.2
PyYAML: 6.0.1
PyZMQ: 25.1.2
relenv: 0.16.0
smmap: Not Installed
timelib: 0.3.0
Tornado: 6.3.3
ZMQ: 4.3.4
Salt Package Information:
Package Type: onedir
System Versions:
dist: debian 12.10 bookworm
locale: utf-8
machine: x86_64
release: 6.1.0-34-amd64
system: Linux
version: Debian GNU/Linux 12.10 bookworm
Description
A file under ext_pillar/file_tree e.g. an openssh host key, works fine in a standard minion setup but results in
Object of type bytes is not JSON serializablewhen using it viasalt-ssh. Debugging with jeanluc on Discord showed that a small patchfixes this issue
Setup
Please be as specific as possible and give set-up details.
Steps to Reproduce the behavior
Easy to reproduce with (soon to be) attached MVE file in Debian 12 VM based on Debian's cloud image.
Example state file failing is
with
Expected behavior
Data should be properly serialized and transferred via ssh tunnel to client
Screenshots
n/a
Versions Report
salt --versions-report
(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.) ``` Salt Version: Salt: 3007.1Python Version:
Python: 3.10.14 (main, Apr 3 2024, 21:30:09) [GCC 11.2.0]
Dependency Versions:
cffi: 1.16.0
cherrypy: unknown
dateutil: 2.8.2
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
Jinja2: 3.1.4
libgit2: Not Installed
looseversion: 1.3.0
M2Crypto: Not Installed
Mako: Not Installed
msgpack: 1.0.7
msgpack-pure: Not Installed
mysql-python: Not Installed
packaging: 23.1
pycparser: 2.21
pycrypto: Not Installed
pycryptodome: 3.19.1
pygit2: Not Installed
python-gnupg: 0.5.2
PyYAML: 6.0.1
PyZMQ: 25.1.2
relenv: 0.16.0
smmap: Not Installed
timelib: 0.3.0
Tornado: 6.3.3
ZMQ: 4.3.4
Salt Package Information:
Package Type: onedir
System Versions:
dist: debian 12.10 bookworm
locale: utf-8
machine: x86_64
release: 6.1.0-34-amd64
system: Linux
version: Debian GNU/Linux 12.10 bookworm