Jessica, try this...
######################################################################
#
# Uncomment lines
#
######################################################################
body common control
{
version => "1.2.3";
bundlesequence => { "testbundle" };
}
# try this on some test data like
# one
# two
# mark one
#mark two
########################################################
bundle agent testbundle
{
files:
"/home/mark/tmp/comment_test"
create => "true",
edit_line => uncomment_lines_matching("\s*mark.*","#");
}
########################################################
bundle edit_line uncomment_lines_matching(regex,comment)
{
replace_patterns:
"#($(regex))$" replace_with => uncomment;
}
########################################################
body replace_with uncomment
{
replace_value => "$(match.1)";
occurrences => "all";
}
Jessica Greer wrote:
> Can I get examples of uncommenting lines from other cf3 users?
>
> Commenting is straightforward with replace_with, but uncommenting seems
> non-trivial. I thought about using getfields(), using my comment
> character as a delimiter, to stuff the remainder of the line into a
> variable I could then use with replace_with. The getfields() function
> doesn't seem to be implemented, though (no matter; it was a messy
> solution anyhow).
>
> I could delete the commented line and replaced with an uncommented one -
> is that what others are doing, or am I missing a simpler way?
>
> Thanks,
> -Jess
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Help-cfengine mailing list
> [email protected]
> https://cfengine.org/mailman/listinfo/help-cfengine
--
Mark Burgess
-------------------------------------------------
Professor of Network and System Administration
Oslo University College, Norway
Personal Web: http://www.iu.hio.no/~mark
Office Telf : +47 22453272
-------------------------------------------------
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine