async fails after running vsphere_guest

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

Has anyone an idea?

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

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

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