I've learned that "body replace_with comment" is called by comment_lines_matching. Thank you, sauer.
Aleksey On Thu, Apr 5, 2012 at 7:53 AM, Aleksey Tsalolikhin <atsaloli.t...@gmail.com> wrote: > Hi. What's the use of "body replace_with comment", please? It's in > the standard library. > > I can get it to run but I don't see how or why anybody would want to use it. > > How does it relate to comment_lines_matching and comment_lines_containing? > > I think the COPBL could be greatly improved by documenting in each > bundle or body how and why it would be used -- like is done right now > with "bundle agent cronjob". > > Yours truly, > Aleksey > > > [root@student93 verticalsysadmin_training_examples]# echo 'I am taking > my dog for a walk' > /tmp/file.txt > [root@student93 verticalsysadmin_training_examples]# cf-agent -f > ./MISC_COPBL_replace_with_comment.cf -b example -KI > >> Using command line specified bundlesequence > -> Promised replacement "# dog" for pattern "^.*(dog).*$" is not > properly convergent while editing /tmp/file.txt > Because the regular expression "^.*(dog).*$" still matches the > end-state replacement string "# dog" > Promise (version not specified) belongs to bundle 'comment_out_dogs' > in file './MISC_COPBL_replace_with_comment.cf' near line 17 > -> Edited file /tmp/file.txt > [root@student93 verticalsysadmin_training_examples]# cat /tmp/file.txt > # dog > [root@student93 verticalsysadmin_training_examples]# > > [root@student93 verticalsysadmin_training_examples]# cat > MISC_COPBL_replace_with_comment.cf > bundle agent example { > > files: > > "/tmp/file.txt" > > edit_line => comment_out_dogs; > > } > > bundle edit_line comment_out_dogs { > > replace_patterns: > > "^.*(dog).*$" > > replace_with => comment("#"); > > > } > > body replace_with comment(c) > { > replace_value => "$(c) $(match.1)"; > occurrences => "all"; > } > [root@student93 verticalsysadmin_training_examples]# _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine