title: Add word to end of line in Ansible
body: <p>I've been trying a lot of lineinfile and replace examples but i can't get it to work.</p>
  
  <p>I have the following lines:</p>
  
  <pre><code>deb-src http://httpredir.debian.org/debian buster main
  deb http://security.debian.org/debian-security buster/updates main
  deb-src http://security.debian.org/debian-security buster/updates main 
  </code></pre>
  
  <p>And i want them to look like this:</p>
  
  <pre><code>deb-src http://httpredir.debian.org/debian buster main contrib
  deb http://security.debian.org/debian-security buster/updates main contrib
  deb-src http://security.debian.org/debian-security buster/updates main contrib
  </code></pre>
  
  <p>I tried to do so with Ansible;</p>
  
  <pre><code>- name: Add contrib repository
    lineinfile:
      dest: /etc/apt/sources.list
      backup: yes
      state: present
      regexp: '^(deb (.*)$)'
      backrefs: yes
      line: '\1 contrib'
    check_mode: no
  </code></pre>
  
  <p>Which kinda works, but after the 2nd run it shows like, e.g.</p>
  
  <pre><code>deb http://security.debian.org/debian-security buster/updates main contrib contrib
  </code></pre>
  
  <p>So it keeps adding the word with every run.</p>
  
  <p>Obviously the lines are not as-is on every system, but they do start with deb or deb-src</p>
  
  <p>Thanks!</p>