title: Ansible is randomly cheating on me
body: <p>I have an asible playbook which is suppose to fix broken XMLs on my SOLR instances:</p>
  
  <pre><code>- hosts: host-solr-master, host-solr-repeater
    become: true
    become_user: user
  
    tasks:
    - name: Fixing corrupted wc-search.xml
      lineinfile:
        path: '{{ solr_catalog_config_dir }}/wc-search.xml'
        regexp: '{{ item.regexp }}'
        line: '{{ item.line }}'
        state: '{{ item.state }}'
      with_items:
        - { regexp: '&lt;\!DOCTYPE.*', line: '', state: 'absent' }
        - { regexp: '\]&gt;', line: '', state: 'absent' }
        - { regexp: '&lt;_config:cores.*', line: '&lt;_config:cores&gt;', state: 'present' }
  
    - name: Preview the changed wc-search.xml
      shell: cat '{{ solr_catalog_config_dir }}/wc-search.xml'
  </code></pre>
  
  <p>I am executing that playbook on Jenkins with Ansible plugin 0.8 (running with Python 2.7.5). The issue I have is that although The jobs claim to replace the desired lines.</p>
  
  <pre><code>TASK [Fixing corrupted wc-search.xml] ******************************************
  ok: [hostname.master] =&gt; (item={u'regexp': u'&lt;\\!DOCTYPE.*', u'line': u'', u'state': u'absent'}) =&gt; {
      "backup": "", 
      "changed": false, 
      "found": 0, 
      "item": {
          "line": "", 
          "regexp": "&lt;\\!DOCTYPE.*", 
          "state": "absent"
      }
  }
  changed: [hostname.repeater] =&gt; (item={u'regexp': u'&lt;\\!DOCTYPE.*', u'line': u'', u'state': u'absent'}) =&gt; {
      "backup": "", 
      "changed": true, 
      "found": 1, 
      "item": {
          "line": "", 
          "regexp": "&lt;\\!DOCTYPE.*", 
          "state": "absent"
      }
  }
  
  MSG:
  
  1 line(s) removed
  
  ok: [hostname.master] =&gt; (item={u'regexp': u'\\]&gt;', u'line': u'', u'state': u'absent'}) =&gt; {
      "backup": "", 
      "changed": false, 
      "found": 0, 
      "item": {
          "line": "", 
          "regexp": "\\]&gt;", 
          "state": "absent"
      }
  }
  changed: [hostname.repeater] =&gt; (item={u'regexp': u'\\]&gt;', u'line': u'', u'state': u'absent'}) =&gt; {
      "backup": "", 
      "changed": true, 
      "found": 1, 
      "item": {
          "line": "", 
          "regexp": "\\]&gt;", 
          "state": "absent"
      }
  }
  
  MSG:
  
  1 line(s) removed
  
  changed: [hostname.repeater] =&gt; (item={u'regexp': u'&lt;_config:cores.*', u'line': u'&lt;_config:cores&gt;', u'state': u'present'}) =&gt; {
      "backup": "", 
      "changed": true, 
      "item": {
          "line": "&lt;_config:cores&gt;", 
          "regexp": "&lt;_config:cores.*", 
          "state": "present"
      }
  }
  
  MSG:
  
  line replaced
  
  ok: [hostname.master] =&gt; (item={u'regexp': u'&lt;_config:cores.*', u'line': u'&lt;_config:cores&gt;', u'state': u'present'}) =&gt; {
      "backup": "", 
      "changed": false, 
      "item": {
          "line": "&lt;_config:cores&gt;", 
          "regexp": "&lt;_config:cores.*", 
          "state": "present"
      }
  }
  </code></pre>
  
  <p>Verified that in task "Preview the changed wc-search.xml".</p>
  
  <pre><code>TASK [Preview the changed wc-search.xml] ***************************************
  changed: [hostname.repeater] =&gt; {
      "changed": true, 
      "cmd": "cat 'PATH_TO/wc-search.xml'", 
      "delta": "0:00:00.023935", 
      "end": "2020-03-16 10:37:23.424572", 
      "rc": 0, 
      "start": "2020-03-16 10:37:23.400637"
  }
  
  STDOUT:
  
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;_config:search-config
      xmlns:_config="http://www.ibm.com/xmlns/prod/commerce/foundation/config"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.ibm.com/xmlns/prod/commerce/foundation/config ../xsd/wc-search.xsd "&gt;
      &lt;_config:server name="BasicConfiguration"&gt;
          &lt;_config:embedded/&gt;
      &lt;/_config:server&gt;
  &lt;_config:cores&gt;
          ...
      &lt;/_config:cores&gt;
  &lt;/_config:search-config&gt;
  
  changed: [hostname.master] =&gt; {
      "changed": true, 
      "cmd": "cat 'PATH_TO/wc-search.xml'", 
      "delta": "0:00:00.036818", 
      "end": "2020-03-16 10:37:23.560608", 
      "rc": 0, 
      "start": "2020-03-16 10:37:23.523790"
  }
  
  STDOUT:
  
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;_config:search-config
      xmlns:_config="http://www.ibm.com/xmlns/prod/commerce/foundation/config"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.ibm.com/xmlns/prod/commerce/foundation/config ../xsd/wc-search.xsd "&gt;
      &lt;_config:server name="BasicConfiguration"&gt;
          &lt;_config:embedded/&gt;
      &lt;/_config:server&gt;
      &lt;_config:cores&gt;
          ...
      &lt;/_config:cores&gt;
      ...
  &lt;/_config:search-config&gt;
  </code></pre>
  
  <p>When I preview the files in servers afterwards, only the file in <code>host-solr-repeater</code> gets updated.</p>
  
  <p>Any idea what could be the reason here? I tried playing the playbook with <code>--flush-cache</code> flag and set <code>keep_remote_files = False</code> in the <code>/etc/ansible/ansible.cfg</code>. Also didn't help.</p>
  
  <p><strong>Note:</strong> One more important thing - once in few builds, the file gets updated on both servers and sometimes even on none of them, so the behavior here is quite random.</p>