title: Ansible : Loop over two register variables using with_items
body: <p>I have stored checksum of local and remote files in two different variables. Now I want to compare those checksum and fail if they don't match. Below is code.</p>
  
  <pre><code>   - name: Get cksum some of files copied locally
       stat:
         path : "{{ item.src }}/{{ item.file }}"
         checksum_algorithm: sha1
       delegate_to: localhost
       with_items: "{{ files }}"
       register: local_files
  
     - name: Get cksum of remote files 
      stat:
        path : "{{ item.dest }}/{{ item.file }}_{{ item.package }}_NEW"
        checksum_algorithm: sha1
      with_items: "{{ files }}"
      register: remote_files
  
    - name : Compare local and remote cksums. Fail if not matched
      debug:
        msg="Checksum don't match"
      failed_when:  item[0].results.stat.checksum !=  item[1].results.stat.checksum
      with_items:
        - "{{ local_files.results }}"
        - "{{ remote_files.results }}"
  </code></pre>
  
  <p>When I run this, I get below error.</p>
  
  <pre><code>FAILED! =&gt; {"failed": true, "msg": "The conditional check 'item[0].results.stat.checksum !=  item[1].results.stat.checksum' failed. The error was: error while evaluating conditional (item[0].results.stat.checksum !=  item[1].results.stat.checksum): dict object has no element 0"}
  </code></pre>
  
  <p>How can I correct it to compare checksum?</p>