0

I try to place / remove a drop in config file based on a PILLAR variable. This was put in highstate/init.sls on my salt master.

I cannot see any syntax error or spacing issues here. What am i doing wrong here?

Here my SLS file

(% if pillar['highstateenabled'] == 'true' %)

enable_highstate:
  file.managed:
    - name: /etc/salt/minion.d/highstate.conf
    - source: salt://common/salt-minion/files/minion.d/highstate.conf
    - template: jinja

(% else %)

disable_highstate:
  file.absent:
    - name: /etc/salt/minion.d/highstate.conf

(% endif %)

And the output during salt-call:

---
local:
    Data failed to compile:
----------
    Rendering SLS 'LAB:common.salt-minion' failed: mapping values are not allowed here; line 4

---

(% if pillar['highstateenabled'] == 'true' %)

enable_highstate:    <======================
  file.managed:
    - name: /etc/salt/minion.d/highstate.conf
    - source: salt://common/salt-minion/files/minion.d/highstate.conf
    - template: jinja

[...]
---

1 Answer 1

2

finally i found the solution myself:

The code above is using the wrong brackets. Instead using "()" it should be curly brackets "{}" and the code is beeing parsed correctly.

The SLS Rendering error does not point to a syntax error here...

{% if pillar['highstate'] == 'enabled' %}

output:
  cmd.run:
  - name: 'echo "highstate_enabled" '

enable_highstate:
  file.managed:
    - name: /etc/salt/minion.d/highstate.conf
    - source: salt://common/salt-minion/files/minion.d/highstate.conf
    - template: jinja

{% else %}

disable_highstate:
  file.absent:
    - name: /etc/salt/minion.d/highstate.conf

{% endif %}

"seems sometimes you don't see the forest because of too many tree's"

Not the answer you're looking for? Browse other questions tagged or ask your own question.