A capture group is a type of backreference. Saltstack, being python based, uses the re.match object to do regular expression matching, which appears to support backreferences, so these backreferences are allowed.
However, you be unable to pass the value of the backreference \1
in the - include_pat
field back to - name
because the - name
field is never processed by the re.match
object. Even if it were, variable scope would prevent you from sharing the backreference between re.match
calls.
Instead, you will need to do one of the following:
Rename all the files in - source
from myfile.conf.template
to myfile.conf
Use cmd.run to do a batch file rename after your file.recurse
and add to your file.recurse
an onchanges pointed to a previous event in order to defeat the idempotency (that is, to prevent it from writing out the .template files every time salt runs). You will also be sure to use a require and onchanges
in your cmd.run that references copy_template
This will have the unfortunate side-effect that you will never be able to update your jinja templates. You will only be able to deploy them the first time - at least not without first deleting what is there, and then re-writing and re-copying from the source.
Use file.managed
for every template file.
For example:
copy_template1:
file.managed:
- name: '{{ service_path }}\template1.conf'
- template: jinja
- source: {{ pillar['locations']['systemtoolsfolder'] }}\template1.conf.template
copy_template2:
file.managed:
- name: '{{ service_path }}\template2.conf'
- template: jinja
- source: {{ pillar['locations']['systemtoolsfolder'] }}\template2.conf.template
...
and so forth