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 }}:
  - 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
Data failed to compile:
Rendering SLS 'base:projects.alip.process-server' failed: could not found    expected ':'; line 177

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.