Commenting out lines

Dear list,

what do you consider best practice when you want to comment out (or in) a certain line in a configuration file? The "lineinfile" module does not seem flexible enough for my taste.

Example: I want to change my etckeeper.conf from

# The VCS to use.
#VCS="hg"
#VCS="git"
VCS="bzr"
#VCS="darcs"

to

# The VCS to use.
#VCS="hg"
VCS="git"
#VCS="bzr"
#VCS="darcs"

In this example I could probably do it by specifying the entire line. But what I'm looking for is something like:

- comment out all lines like ^VCS
- comment in the line like ^#VCS.*git

But in other cases I wouldn't know how the line exactly looks. I would prefer to look for a pattern and enable that.

Puppet has Augeas support for that purpose. What would you recommend?

Kindly
…Christoph

lineinfile can be fine for small use cases, but often, the better is to template the whole file.