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 a for Loop where we have multiple files to be replaced? Is there additional code that I am missing in the above FOR Loop?

  • 2
    You can define a pillar the python syntax and use python to read the file list. docs.saltstack.com/en/latest/ref/renderers/all/… – petrchpetr Dec 28 '18 at 13:36
  • Will try the suggestion. – Narasimha Jan 2 '19 at 8:09
  • Please describe what you are trying to achieve. Could you explain why you are trying to replace files? – 030 Dec 24 '19 at 15:09

Browse other questions tagged or ask your own question.