Open joseph-ireland opened 3 years ago
Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here’s some information that may help as you continue your Salt journey. Please be sure to review our Code of Conduct. Also, check out some of our community resources including:
There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar. If you have additional questions, email us at saltproject@vmware.com. We’re glad you’ve joined our community and look forward to doing awesome things with you!
@joseph-ireland Thanks for the report. I was able to reproduce this one and it's definitely a bug.
Looking further into this, it seems yamlex has always tried to render all strings with quotes everywhere, which seems very odd.
https://github.com/saltstack/salt/blob/master/salt/serializers/yamlex.py#L370
I'm not familiar with the code base, but I guess that this odd __str__
operator would typically be discarded due to some extra serialization step, and since salt-ssh runs the whole thing in one process, the __str__
operator sticks around.
@joseph-ireland I've verified that for this particular use case the following change does produce the expected results:
diff --git a/salt/serializers/yamlex.py b/salt/serializers/yamlex.py
index bf9b278248..fbb685e108 100644
--- a/salt/serializers/yamlex.py
+++ b/salt/serializers/yamlex.py
@@ -384,7 +384,7 @@ class SLSString(str):
"""
def __str__(self):
- return serialize(self, default_style='"')
+ return serialize(self)
def __repr__(self):
return serialize(self, default_style='"')
We just need to verify that making this change doesn't break something else.
FYI: #47085 appears to be the same bug.
Description Strings defined in a pillar file using yamlex end up quoted when rendered in jinja to the state file.
Setup
/srv/pillar/weird_quotes.sls:
/srv/salt/weird_quotes.sls:
Steps to Reproduce the behavior
salt-ssh <host> state.apply weird_quotes -l debug
output log
``` [DEBUG ] Reading configuration from /etc/salt/master [DEBUG ] Changed git to gitfs in master opts' fileserver_backend list [DEBUG ] Configuration file path: /etc/salt/master [WARNING ] Insecure logging configuration detected! Sensitive data may be logged. [DEBUG ] MasterEvent PUB socket URI: /var/run/salt/master/master_event_pub.ipc [DEBUG ] MasterEvent PULL socket URI: /var/run/salt/master/master_event_pull.ipc [DEBUG ] LazyLoaded flat.targets [DEBUG ] LazyLoaded jinja.render [DEBUG ] LazyLoaded yaml.render [DEBUG ] compile template: /etc/salt/roster [DEBUG ] Jinja search path: ['/var/cache/salt/master/files/base'] [DEBUG ] LazyLoaded roots.envs [DEBUG ] pygit2 gitfs_provider enabled [DEBUG ] Created gitfs object with uninitialized remotes [DEBUG ] LazyLoaded gitfs.envs [DEBUG ] Could not LazyLoad roots.init: 'roots.init' is not available.Expected behavior
/test_example/
should be created, instead/"test"_example/
is createdVersions Report
salt --versions-report
(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.) ``` [jireland@bell pillar]$ salt --versions-report Salt Version: Salt: 3001.7 Dependency Versions: cffi: 1.14.0 cherrypy: unknown dateutil: 2.6.1 docker-py: 3.5.0 gitdb: Not Installed gitpython: Not Installed Jinja2: 2.8.1 libgit2: 1.0.0 M2Crypto: 0.35.2 Mako: Not Installed msgpack-pure: Not Installed msgpack-python: 0.6.2 mysql-python: Not Installed pycparser: 2.20 pycrypto: 2.6.1 pycryptodome: Not Installed pygit2: 1.2.1 Python: 3.6.8 (default, Apr 2 2020, 13:34:55) python-gnupg: Not Installed PyYAML: 3.12 PyZMQ: 17.0.0 smmap: Not Installed timelib: Not Installed Tornado: 4.5.3 ZMQ: 4.1.4 System Versions: dist: centos 7 Core locale: UTF-8 machine: x86_64 release: 3.10.0-862.9.1.el7.x86_64 system: Linux version: CentOS Linux 7 Core ```Additional context Add any other context about the problem here.