Remove lines from a file?
Is there any way to ensure that a file must not contain any lines matching a particular substring or regex?
For example, say I want to ensure that file /etc/something.conf does not have any lines that begin with "riskyparam ..." I don't know what value riskyparam is set to, and I don't know how many times it appears in the file, but I want to remove all of them if any are there.
file_line with a match and ensure=>absent seemed at first like it might be a way to do this, but it turns out it doesn't work. You must have a line=> in the
file_line, and that line is some specific string (even if it's expanded from variables or functions), not a regex or substring match. With ensure=>absent, file_line would remove anything matching that line completely. But when I don't know in advance what the offending line might contain, and want to remove all variations of it, that won't work.
Is there any way to do this?
Edit: Of course one can do pretty much anything with an exec, since you can write a script to do it. I'm looking for a way to avoid having an exec run a shell every single time the puppet agent runs.