title: Ansible async task collecting results: could not find job
body: <p>I'm trying to fire-and-forget some tasks and collect results after that. Here's my playbook:</p>
  
  <pre><code>---
  - hosts: node2
    gather_facts: yes 
    tasks:
      - name: 'Some long script no 1 on node2'
        shell: "time sleep $[ ( $RANDOM % 20 )  + 20 ]s" 
        async: 40
        poll: 0
        register: script1 
  
      - name: 'Another long script no 2 on node2'
        shell: "time sleep $[ ( $RANDOM % 20 )  + 20 ]s" 
        async: 40
        poll: 0
        register: script2
  
  - hosts: node2
    tasks:
      - name: "Collect results"
        async_status:
          jid: loop_item.ansible_job_id
        loop:
          - script1
          - script2
        loop_control:
          loop_var: loop_item
        register: async_poll_results
        until: async_poll_results.finished
        retries: 30 
  </code></pre>
  
  <p>When I run it, I receive following error:</p>
  
  <pre><code>PLAY [node2]     ****************************************************************************************************************************
  TASK [Gathering Facts] ******************************************************************************************************************
  ok: [hostname]
  
  TASK [Some long script no 1 on node2] ***************************************************************************************************
  changed: [hostname] =&gt; {"ansible_job_id": "814448842231.125544", "changed": true, "finished": 0, "results_file": "/home/external.kamil.sacharczuk/.ansible_async/814448842231.125544", "started": 1}
  
  TASK [Another long script no 2 on node2] ************************************************************************************************
  changed: [hostname] =&gt; {"ansible_job_id": "586999441005.125616", "changed": true, "finished": 0, "results_file": "/home/external.kamil.sacharczuk/.ansible_async/586999441005.125616", "started": 1}
  
  PLAY [node2] ****************************************************************************************************************************
  
  TASK [Gathering Facts] ******************************************************************************************************************
  ok: [hostname]
  
  TASK [Collect results] ******************************************************************************************************************
  failed: [hostname] (item=script1) =&gt; {"ansible_job_id": "loop_item.ansible_job_id", "attempts": 1, "changed": false, "finished": 1, "loop_item": "script1", "msg": "could not find job", "started": 1}
  failed: [hostname] (item=script2) =&gt; {"ansible_job_id": "loop_item.ansible_job_id", "attempts": 1, "changed": false, "finished": 1, "loop_item": "script2", "msg": "could not find job", "started": 1}
  to retry, use: --limit @xxxxxxxxx
  
  PLAY RECAP ******************************************************************************************************************************
  hostname         : ok=4    changed=2    unreachable=0    failed=1   
  </code></pre>
  
  <p>Don't really know why I receive this "could not find job". I tried to run this "collect" tasks localy first, than I figured out, that this job results are stored on node2, so I run it there. Tried with or without gathering facts. Tried also use</p>
  
  <pre><code>hostvars['hostname'][loop_item][ansible_job_id]
  </code></pre>
  
  <p>but this gave me same error as here. </p>
  
  <p>Any help would be much appreciated!</p>
  
  <p>PS. I am running ansible 2.6.1</p>