title: Ansible: append a string to an existing line in a file
body: <p>I am using ansible module to edit the manifest file for kube-apiserver</p>
  
  <pre><code>    - --feature-gates=AdvancedAuditing=true
  </code></pre>
  
  <p>I want to append new feature-gate like </p>
  
  <pre><code>    - --feature-gates=AdvancedAuditing=true,TTLAfterFinished=true
  </code></pre>
  
  <p>I tried many thing, one of which -</p>
  
  <pre><code>- name: append TTLAfterFinished to existing list of feature-gates
    lineinfile:
      path: item.0.item.file_path
      backrefs: yes
      regexp: "^(.*feature-gates.*)$"
      line: '\1,TTLAfterFinished=true'
  </code></pre>
  
  <p>With no luck.. :( Any help ?</p>