title: Ansible fileinline not working with loop
body: <p>I am trying to add or edit multiple lines in a file using <code>lineinfile</code> but not working. I am using below code with no luck Ref: <a href="https://stackoverflow.com/questions/24334115/ansible-lineinfile-for-several-lines">ansible: lineinfile for several lines?</a></p>
  
  <pre><code># vim /etc/ansible/playbook/test-play.yml 
  
  - hosts: tst.wizvision.com
    tasks:
    - name: change of line
      lineinfile:
        dest: /root/test.txt
        regexp: "{{ item.regexp }}"
        line: "{{ item.line }}"
        backrefs: yes
        with_items:
        - { regexp: '^# line one', line: 'NEW LINE ONE' }
        - { regexp: '^# line two', line: 'NEW LINE TWO' }
  </code></pre>
  
  <p><strong>Ansible Error:</strong> </p>
  
  <pre><code># ansible-playbook test-2.yml
  </code></pre>
  
  <p>TASK [change of line] **********************************************************</p>
  
  <blockquote>
    <p>fatal: [localhost]: FAILED! => {"failed": true, "msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: 'item' is undefined\n\nThe error appears to have been in '/etc/ansible/playbook/test-2.yml': line 3, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n tasks:\n - name: change of line\n ^ here\n"}</p>
  </blockquote>