# Commenting out lines

**URL:** <https://forum.ansible.com/t/commenting-out-lines/14714>\
**Category:** Ansible Project\
**Created:** [March 6, 2014, 5:44pm UTC](https://forum.ansible.com/t/commenting-out-lines/14714 "2014-03-06T17:44:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christoph\_Haas](https://avatars.discourse-cdn.com/v4/letter/c/3e96dc/32.png) [@Christoph\_Haas](https://forum.ansible.com/u/Christoph_Haas)\
**Post date:** [March 6, 2014, 5:44pm UTC](https://forum.ansible.com/t/commenting-out-lines/14714/1 "2014-03-06T17:44:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [March 6, 2014, 6:26pm UTC](https://forum.ansible.com/t/commenting-out-lines/14714/2 "2014-03-06T18:26:11Z")

</div>

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