# async fails after running vsphere\_guest

**URL:** <https://forum.ansible.com/t/async-fails-after-running-vsphere-guest/23557>\
**Category:** Ansible Project\
**Created:** [January 25, 2017, 3:21pm UTC](https://forum.ansible.com/t/async-fails-after-running-vsphere-guest/23557 "2017-01-25T15:21:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tim3](https://avatars.discourse-cdn.com/v4/letter/t/f14d63/32.png) [@Tim3](https://forum.ansible.com/u/Tim3)\
**Post date:** [January 25, 2017, 3:21pm UTC](https://forum.ansible.com/t/async-fails-after-running-vsphere-guest/23557/1 "2017-01-25T15:21:42Z")

</div>

I try to run the following tasks like shown below.

`

- name: add test host (fire and forget)  
vsphere\_guest:  
vcenter\_hostname: srv-vcenter01.ansible.local  
username: administrator@vsphere.ansible.local  
password: P@ssw0rd  
guest: “{{item.hostname}}”  
from\_template: yes  
template\_src: temp-win-2k12-r2  
esxi:  
datacenter: Ansible-DC  
hostname: srv-esx02.ansible.local  
vm\_extra\_config:  
folder: VMs  
with\_items: “{{ serverlist }}”  
async: 1800  
poll: 0  
register: sleeper1

- name: check fire and forget  
async\_status:  
jid: “{{ sleeper1.ansible\_job\_id }}”  
register: job\_result  
until: job\_result.finished  
retries: 30  
`

I want to start the set of async tasks and then check their status inside “until” loop.  
During the checking ansible fails with error “‘dict object’ has no attribute ‘ansible\_job\_id’”  
Nearly same problem like [here](https://github.com/ansible/ansible/issues/12254)

Has anyone an idea?

---

<div class="post-metadata">

**Author:** ![Stankovic\_Marko](https://avatars.discourse-cdn.com/v4/letter/s/e495f1/32.png) [@Stankovic\_Marko](https://forum.ansible.com/u/Stankovic_Marko)\
**Post date:** [January 25, 2017, 3:49pm UTC](https://forum.ansible.com/t/async-fails-after-running-vsphere-guest/23557/2 "2017-01-25T15:49:32Z")

</div>

Nearly the same, but you missed the fact that sleeper1 variable contains "result":  
"When using register with a loop, the data structure placed in the variable will contain a results attribute that is a list of all responses from the module."  
[http://docs.ansible.com/ansible/playbooks\_loops.html#using-register-with-a-loop](http://docs.ansible.com/ansible/playbooks_loops.html#using-register-with-a-loop)

You need something like  
with\_items: "{{ sleeper1.results }}"  
at the end of "check fire and forget" and {{ item.ansible\_job\_id }} instead of {{ sleeper1.ansible\_job\_id }}

Cheers,  
Marko

---

<div class="post-metadata">

**Author:** ![Tim3](https://avatars.discourse-cdn.com/v4/letter/t/f14d63/32.png) [@Tim3](https://forum.ansible.com/u/Tim3)\
**Post date:** [January 26, 2017, 7:48am UTC](https://forum.ansible.com/t/async-fails-after-running-vsphere-guest/23557/3 "2017-01-26T07:48:26Z")

</div>

Perfect, that brought me a step further! Still having a problem (check back on fire-and-forget task doesn’t do anything when the task is done). But anyways thank you very much Marko!

Regards, Tim
