salt: [BUG] adding ignore spacing jinja flags will kill a build with "mapping values don't belong here"

Description The following code, which worked fine before 3005, currently on 3005.1, but fails now b/c of spacing issues. This works:

{% set user_home_folder = args['home'] %}
{% set group = username %}

create_plugin_dir_{{username}}:
  file.directory:
    - name: "{{user_home_folder}}/.oh-my-zsh/custom/plugins"
    - user: {{username}}
    - makedirs: True

This fails

{%- set user_home_folder = args['home'] -%}
{%- set group = username -%}

create_plugin_dir_{{username}}:
  file.directory:
    - name: "{{user_home_folder}}/.oh-my-zsh/custom/plugins"
    - user: {{username}}
    - makedirs: True

Setup The above is enough to recreate the issue, the {{username}} is set in a for username, args in pillar.get('foo').items()

The removal of spaces seemed to have been allowed before 3005, as i’ve had this zsh state in my salt repo for a long while, but currently, it must be put on the same line, or something…I would love to tell you what something is but the only error message is that “mapping values are not allowed in this context”. But all files run through a yaml linter/checker returns valid yaml.

  • on-prem machine
  • VM (Virtualbox, KVM, etc. please specify)
  • VM running on a cloud service, please be explicit and add details
  • container (Kubernetes, Docker, containerd, etc. please specify)
  • or a combination, please be explicit
  • jails if it is FreeBSD
  • classic packaging
  • onedir packaging
  • used bootstrap to install

Steps to Reproduce the behavior Add the above yaml to a state file and the merged file is not valid yaml, there is not a better explanation or output, even if i do a test_template it fails with the random error that you have to rip everything apart to try to find.

Expected behavior It should parse the {%- set foo = bar -%} that is followed by an extra newline, as you can see in the example above. Or emit a fatal error, Other than “mapping values don’t belong here”

Screenshots The error message is above, that is all that exists even in debug mode.

Versions Report Tested on both 3005 master and minion and 3005.1 master and minion.

Additional context I realize this may report need a little love in the form of a bug, but it took me about 6 hours to find this so i’m going to just go fix the issue in each of my 4 vpcs. and stop working for the night 😉

I’ll come back to it later, hopefully the information is sufficient to get someone started. Thanks

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 16 (6 by maintainers)

Most upvoted comments

That’s a different error because you told slsutil.renderer to parse it as yaml instead of jinja.

That example will indeed fail, because it will render to

include:
  - users
zsh:
  pkg.latest:
    - require:
      - sls: usersecho username:
  cmd.run

That behaviour did not change between 3004 and 3005.