I am using saltstack state pattern and replace to match a pattern and replace with a new pattern. My init.sls file executes below:
`modify_script.sh:
file.replace:
- name: /path/to/script.sh
- pattern: /aaa/bbb
- repl: /aaa/ccc
- pattern: /xxx/yyy
- repl: /xxx/zzz`
The above works good if I use a single pattern and replace. This fails for multiple patterns and replaces as shown above. How to achieve multiple pattern replace for two or more patterns in a single file?
Secondly, I have multiple files in a directory which requires a pattern match and replace.
modify_script.sh:
file.replace:
- name: /path/to/dir [having multiple files which require update]
- pattern: /aaa/bbb
- repl: /aaa/ccc
Can I match the patterns for all the files under directory? I wouldn't want to match and replace a single file individually. Please advise.