title: Delete only the first occurence of the line in a file using Ansible
body: <p>I am using ansible v2.2.1 and I need to remove only the first occurrence of a line in file. So my ansible playbook is as follows.</p>
  
  <pre><code>---   
  - hosts: localhost
    tasks:
    - name: read file content
      command: cat occurence.txt
      register: fc
    - debug: var=fc
  
    - debug: msg="{{ item }}"
      with_items:
       - "{{ fc.stdout_lines }}"
  
    - name: first occurence in file
      shell: sed -i '0,/{{ item }}/{/{{ item }}/d;}' occurence.txt
      with_items:
       - "{{ fc.stdout_lines }}"
      register: remove
    - debug: var=remove
  </code></pre>
  
  <p>And <strong>occurence.txt</strong> file has following content</p>
  
  <pre><code>this is apple
  this is apple
  this is banana
  this is apple
  this is orange
  </code></pre>
  
  <p>How can I delete only the first occurrence of line "this is apple" and leave rest of the lines?</p>