Skip to content

async_status

Collection Note

This module is part of the ansible.builtin collection. To install the collection, use:

ansible-galaxy collection install ansible.builtin
Added in version 0.5.

Synopsis

  • This module gets the status of an asynchronous task.
  • This module is also supported for Windows targets.

Parameters

Parameter Defaults / Choices Comments
jid
str
required
Job or task identifier
mode
str
Default: status
Choices: cleanup, status
If V(status), obtain the status.
If V(cleanup), clean up the async job cache (by default in C(~/.ansible_async/)) for the specified job O(jid), without waiting for it to finish.

Examples

---
- name: Asynchronous dnf task
  ansible.builtin.dnf:
    name: docker-io
    state: present
  async: 1000
  poll: 0
  register: dnf_sleeper

- name: Wait for asynchronous job to end
  ansible.builtin.async_status:
    jid: '{{ dnf_sleeper.ansible_job_id }}'
  register: job_result
  until: job_result.finished
  retries: 100
  delay: 10

- name: Clean up async file
  ansible.builtin.async_status:
    jid: '{{ dnf_sleeper.ansible_job_id }}'
    mode: cleanup

Return Values

Key Data Type Description Returned
ansible_job_id str The asynchronous job id success
erased str Path to erased job file when file is erased
finished int Whether the asynchronous job has finished (V(1)) or not (V(0)) always
started int Whether the asynchronous job has started (V(1)) or not (V(0)) always
stderr str Any errors returned by async_wrapper always
stdout str Any output returned by async_wrapper always

Authors

  • Ansible Core Team
  • Michael Dehaan