[kwlug-disc] Saltstack multi-line replace

Paul Nijjar paul_nijjar at yahoo.ca
Fri Apr 3 17:42:34 EDT 2020


As I have been learning Salt I have been figuring out different idioms
for editing files. One way is to take control of the entire file
(file.managed). Another is to edit line by line, using regexps to find
the lines (file.line) . Now I am in a situation where there is a file
I would prefer not to manage fully, but for which I cannot figure out
how to edit lines because there is not enough context.


The file is YAML, and looks something like this: 

video_resolution:
  high:
    - fooblaz: xyz
    - quality: 200
  medium: 
    - fooblaz: xyz
    - quality: 100
  low:
    - fooblaz: zyy
    - quality: 75


Each of these elements has a "quality" element I would like to
twiddle. I do not want all of the elements to be the same, and I want
to twiddle them independently.

file.managed would work but then I have to control a big file that
might be changing in other ways. 

I cannot figure out how to use file.line . 

Are there other options?

- Paul


-- 
Events: https://feeds.off-topic.kwlug.org 
Blog: http://pnijjar.freeshell.org




More information about the kwlug-disc mailing list