saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Get access to the Salt software package repository here:
https://repo.saltproject.io/
Apache License 2.0
14.16k stars 5.48k forks source link

serializers.yamlex is doing something weird with its string representation #47085

Open mattp- opened 6 years ago

mattp- commented 6 years ago

Description of Issue/Question

when using yamlex,

#!yamlex
/srv:
  file.directory:
    - makedirs: True
    - group: root
    - user: root
    - mode: 755

the following fails

mmp-sl-test-1:
----------
          ID: "/srv"
    Function: file.directory
      Result: False
     Comment: Group "root" is not available
     Started: 15:26:39.835190
    Duration: 9.279 ms
     Changes:

if you remove the try guard,

KeyError: 'getgrnam(): name not found: "root"'

it seems to be making the root string not actually root. when evaluating group == 'root' before the getgrnam() it evaluated as true, so it's likely something with utf8 encoding that yamlex is doing.


Salt Version:
           Salt: 2018.3.0-2279-g68546d2

Dependency Versions:
           cffi: 1.11.5
       cherrypy: unknown
       dateutil: 2.6.1
      docker-py: 3.1.4
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.10
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: 0.29.0
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.5.6
   mysql-python: Not Installed
      pycparser: 2.18
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.14 (default, Mar 14 2018, 09:26:40)
   python-gnupg: Not Installed
         PyYAML: 3.12
          PyZMQ: 17.0.0
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.5.3
            ZMQ: 4.1.6

System Versions:
           dist: redhat 7.3 Maipo
         locale: UTF-8
        machine: x86_64
        release: 3.10.0-514.6.1.el7.x86_64
         system: Linux
        version: Red Hat Enterprise Linux Server 7.3 Maipo```
mattp- commented 6 years ago

26396

gtmanfred commented 6 years ago

Can you provide the output of --versions-report like the issues template requests, so that we can attempt to replicate this issue?

Daniel

mattp- commented 6 years ago

updated with version-report

gtmanfred commented 6 years ago

Also, make sure you put newlines before and after the triple backtics, otherwise they do not do what you are expecting them to do.

gtmanfred commented 6 years ago

I am able to replicate this issue.

[CRITICAL] root
[CRITICAL] <class 'salt.serializers.yamlex.SLSString'>
[ERROR   ] Group "root" is not available

It looks like the grp.getgrnam does not like the yamlex SLSString format for some reason.

Thanks for reporting, Daniel

gtmanfred commented 6 years ago

Looks like this is the way it has been for a while, also broken in 2017.7.

Thanks, Daniel

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

pruiz commented 5 years ago

AFAIK this is still happening.

On Tue, Jul 30, 2019 at 4:30 PM stale[bot] notifications@github.com wrote:

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/saltstack/salt/issues/47085?email_source=notifications&email_token=AABOV6LFGE4BG7ERE6IJ6HTQCBGBRA5CNFSM4E2WOBBKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3EFERA#issuecomment-516444740, or mute the thread https://github.com/notifications/unsubscribe-auth/AABOV6NOTVT7C5VXQS3FA2TQCBGBRANCNFSM4E2WOBBA .

stale[bot] commented 5 years ago

Thank you for updating this issue. It is no longer marked as stale.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

stale[bot] commented 4 years ago

Thank you for updating this issue. It is no longer marked as stale.

CrackerJackMack commented 1 year ago

I am also experiencing this issue. The workaround mentioned in #60359 didn't seem to work when the top.sls is {{ saltenv }}:

I used _serializers and then on the master salt-run saltutil.sync_all saltenv=prod and it appears in cache/master/extmods.