title: Commenting out a line with Ansible lineinfile module
body: <p>I find it hard to believe there isn't anything that covers this use case but my search has proved fruitless.</p>
  
  <p>I have a line in <code>/etc/fstab</code> to mount a drive that's no longer available:</p>
  
  <pre><code>//archive/Pipeline /pipeline/Archives cifs ro,credentials=/home/username/.config/cifs 0   0
  </code></pre>
  
  <p>What I want is to change it to </p>
  
  <pre><code>#//archive/Pipeline /pipeline/Archives cifs ro,credentials=/home/username/.config/cifs 0   0
  </code></pre>
  
  <p>I was using this </p>
  
  <pre><code>---
  - hosts: slurm
    remote_user: root
  
    tasks:
      - name: Comment out pipeline archive in fstab
        lineinfile:
          dest: /etc/fstab
          regexp: '^//archive/pipeline'
          line: '#//archive/pipeline'
          state: present
        tags: update-fstab
  </code></pre>
  
  <p>expecting it to just insert the comment symbol (#), but instead it replaced the whole line and I ended up with </p>
  
  <pre><code>#//archive/Pipeline
  </code></pre>
  
  <p>is there a way to glob-capture the rest of the line or just insert the single comment char?</p>
  
  <pre><code> regexp: '^//archive/pipeline *'
   line: '#//archive/pipeline *'
  </code></pre>
  
  <p>or</p>
  
  <pre><code> regexp: '^//archive/pipeline *'
   line: '#//archive/pipeline $1'
  </code></pre>
  
  <p>I am trying to wrap my head around lineinfile and from what I"ve read it looks like insertafter is what I'm looking for, but "insert after" isn't what I want?</p>