Quantcast
Channel: Ask Puppet: Puppet DevOps Q&A Community - RSS feed
Viewing all articles
Browse latest Browse all 6104

Remove lines from a file?

$
0
0
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?

Viewing all articles
Browse latest Browse all 6104

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>