question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Rendering SLS 'base:git.prod.salt.3001up' failed: could not find expected ':'

See original GitHub issue

Description Getting following error message when trying to upgrade salt-minion to 3001.

 - Rendering SLS 'base:git.prod.salt.3001up' failed: could not find expected ':'

Setup

  • Correct indentation
[me@salt01 salt]$ cat 3001up.sls

{% for key, repo in salt['pkg.list_repos']().items() %}
{% if repo.get('enabled', '1') == '1' and 'saltstack' in key %}
Remove repo {{ key }}:
  pkgrepo.absent:
      - name: {{ key }}
{% endif %}
{% endfor %}

{% if grains['os_family'] == 'RedHat' %}
install_at:
  pkg.installed:
      - name: at
      - name: curl
atd_service:
  service.running:
      - name: atd
      - enable: True
upgrade_salt_minion:
  cmd.run:
      - name: |
          echo "systemctl stop salt-minion.service
          yum -y remove salt-minion
          yum -y remove PyYAML m2crypto python-zmq zeromq python-crypto python-msgpack
          yum -y autoremove
          rm -rf /var/cache/salt/minion
          curl -Ls https://bootstrap.saltstack.com | sh -s -- -X -x python3 stable
          [ -f /etc/salt/minion.rpmsave ] && \
          ( cp -f /etc/salt/minion /etc/salt/minion.bak; \
          mv -f /etc/salt/minion.rpmsave /etc/salt/minion )
          systemctl is-enabled salt-minion.service || \
          (systemctl preset salt-minion.service && \
          systemctl enable salt-minion.service)
          systemctl start salt-minion.service" | at now
{% endif %}
[me@salt01 salt]$

  • Wrong indentation starting from echo line that create this confusing message.
[me@salt01 salt]$ cat  3001up-ident-off.sls

{% for key, repo in salt['pkg.list_repos']().items() %}
{% if repo.get('enabled', '1') == '1' and 'saltstack' in key %}
Remove repo {{ key }}:
  pkgrepo.absent:
      - name: {{ key }}
{% endif %}
{% endfor %}

{% if grains['os_family'] == 'RedHat' %}
install_at:
  pkg.installed:
      - name: at
      - name: curl
atd_service:
  service.running:
      - name: atd
      - enable: True
upgrade_salt_minion:
  cmd.run:
      - name: |
        echo "systemctl stop salt-minion.service
        yum -y remove salt-minion
        yum -y remove PyYAML m2crypto python-zmq zeromq python-crypto python-msgpack
        yum -y autoremove
        rm -rf /var/cache/salt/minion
        curl -Ls https://bootstrap.saltstack.com | sh -s -- -X -x python3 stable
        [ -f /etc/salt/minion.rpmsave ] && \
        ( cp -f /etc/salt/minion /etc/salt/minion.bak; \
        mv -f /etc/salt/minion.rpmsave /etc/salt/minion )
        systemctl is-enabled salt-minion.service || \
        (systemctl preset salt-minion.service && \
        systemctl enable salt-minion.service)
        systemctl start salt-minion.service" | at now
{% endif %}
[me@salt01 salt]$

Steps to Reproduce the behavior (Include debug logs if possible and relevant)

Expected behavior

Hoping to see error about wrong indentation starting from “echo” line.

Screenshots If applicable, add screenshots to help explain your problem.

Versions Report

  • version 3000.3 and 3001
Salt Version:
           Salt: 3000.3

Dependency Versions:
           cffi: 1.6.0
       cherrypy: unknown
       dateutil: 1.5
      docker-py: Not Installed
          gitdb: 0.6.4
      gitpython: 1.0.1
         Jinja2: 2.7.2
        libgit2: 0.26.3
       M2Crypto: 0.31.0
           Mako: 0.8.1
   msgpack-pure: Not Installed
 msgpack-python: 0.6.2
   mysql-python: 1.2.5
      pycparser: 2.14
       pycrypto: 2.6.1
   pycryptodome: 3.9.7
         pygit2: 0.26.4
         Python: 2.7.5 (default, Apr  2 2020, 13:16:51)
   python-gnupg: 0.4.3
         PyYAML: 3.11
          PyZMQ: 15.3.0
          smmap: 0.9.0
        timelib: 0.2.4
        Tornado: 4.5.3
            ZMQ: 4.1.4

System Versions:
           dist: centos 7.8.2003 Core
         locale: UTF-8
        machine: x86_64
        release: 3.10.0-1127.8.2.el7.x86_64
         system: Linux
        version: CentOS Linux 7.8.2003 Core

Additional context Add any other context about the problem here.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
terminalmagecommented, Jul 9, 2020

This is not a bug. This is expected behavior. There is no way for Salt to tell you what you did wrong here, because what you wrote is not valid YAML. So, PyYAML cannot successfully load it into a data structure for Salt to analyze and tell you what is wrong.

And it’s not just Salt, either. Google “online YAML parser” and try each of the below two blocks:

Wrong indentation, invalid YAML

hello:
  world:
    - foo: |
      one
      two
      three

Correct indentation, valid YAML

hello:
  world:
    - foo: |
        one
        two
        three

This PR adds some documentation for this particular case, but IMO there’s little (if anything) else that can be done. Salt can’t load invalid YAML.

1reaction
tjyangcommented, Jul 9, 2020

@terminalmage , thanks for PR to document this cryptic message.

Read more comments on GitHub >

github_iconTop Results From Across the Web

State Rendering Issue : r/saltstack
I keep getting the error "Rendering SLS 'base:plex' failed: did not find expected alphabetic or numeric character". I have read through my state ......
Read more >
saltstack return inconsistent errors
The key point is that re-running salt-call usually succeeds without problem. If it doesn't, the next run will. And maybe the run after...
Read more >
Rendering SLS error, what am I not seeing
I can't figure out what the problem is, YAML or misunderstanding the SaltStack documentation etc. I have not enabled debugging yet.
Read more >
Dealing with YAML configuration problems - Salt ...
In this chapter, you will learn about the most common mistakes and how to avoid ... failed to compile: ---------- Rendering SLS apache...
Read more >
Why is IF failing with satl state file from Jenkins?
The jinja syntax error is caused by the {{ around your job var. Those curly braces are not required as you are already...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found