removing matching line from file

794 views
Skip to first unread message

Philip Brown

unread,
Mar 19, 2013, 5:01:16 PM3/19/13
to puppet...@googlegroups.com
I've been using the stdlib::file_line resource happily for a bit now, but then ran into a problem

I have a class, which can be simplified as follows

class prop(propval)
{
  file_line {conffile:
     line=>"PROPERTY=propval"
  }
}


However, I'm attempting to plan for the future, and it sounds rather useful to have the ability to remove the property completely.
The app I'm configuring this for, expects to see NO "PROPERTY=" value, if you want to disable this feature.

Unfortunately, I dont see a way to do it, without some ugly exec() calls.

In other words, what I'd LIKE to be able to do, is someting like

  file_line{ conffile:
    line=>"PROPERTY=",
    match=> "^PROPERTY=.*",
    ensure=>absent,
  }

and then have file_line remove a line, if present, that matches "PROPERTY=".

After all, it can do

   replace  "^PROPERTY="  with "PROPERTY=foo"

So surely there's some way to do

   replace  "^PROPERTY="  with "[empty]"

?


尹川

unread,
Mar 19, 2013, 9:04:38 PM3/19/13
to puppet...@googlegroups.com
thank you for let me know there is a stdlib module,many thanks!





--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To post to this group, send email to puppet...@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
一片树林里分出两条路——
        而我选择了人迹更少的一条,
        从此决定了我一生的道路。
Reply all
Reply to author
Forward
0 new messages