1

Salt stack state to recursively loop over a directory without explicitly specifying file names. Added single and multiple quotes, that didn't help. I don't wish to specify each file for a file replace. I want to loop all files under dir for replace.

{% for file in "/path/{{ to }}/dir" %}
{{ file }}:
file.replace:
  - name: {{ file }}
  - pattern: /from/
  - repl: /{{ to }}/
  - backup: False
{% endfor %}

I tried single quotes and multiple quotes, but see the error. I see that the files are not read one by one as expected for a replace.

":{"return":"ERROR: Minions returned with non-zero exit code
d01cmw004:
Data failed to compile:
----------
Rendering SLS 'base:projects.alip.process-server' failed: could not found    expected ':'; line 177
---
[...]

Can we specify a directory in a for Loop where we have multiple files to be replaced? Is there additional code that I am missing in the above FOR Loop?

Browse other questions tagged or ask your own question.