ansible.builtin.async_status (v2.16.5) — module

Obtain status of asynchronous task

| "added in version" 0.5 of ansible.builtin"

Authors: Ansible Core Team, Michael DeHaan

This plugin has a corresponding action plugin.

Install Ansible via pip

Install with pip install ansible-core==2.16.5

Description

This module gets the status of an asynchronous task.

This module is also supported for Windows targets.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
---
- name: Asynchronous yum task
  ansible.builtin.yum:
    name: docker-io
    state: present
  async: 1000
  poll: 0
  register: yum_sleeper
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Wait for asynchronous job to end
  ansible.builtin.async_status:
    jid: '{{ yum_sleeper.ansible_job_id }}'
  register: job_result
  until: job_result.finished
  retries: 100
  delay: 10
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Clean up async file
  ansible.builtin.async_status:
    jid: '{{ yum_sleeper.ansible_job_id }}'
    mode: cleanup

Inputs

    
jid:
    description:
    - Job or task identifier
    required: true
    type: str

mode:
    choices:
    - cleanup
    - status
    default: status
    description:
    - 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.
    type: str

Outputs

ansible_job_id:
  description: The asynchronous job id
  returned: success
  sample: '360874038559.4169'
  type: str
erased:
  description: Path to erased job file
  returned: when file is erased
  type: str
finished:
  description: Whether the asynchronous job has finished (V(1)) or not (V(0))
  returned: always
  sample: 1
  type: int
started:
  description: Whether the asynchronous job has started (V(1)) or not (V(0))
  returned: always
  sample: 1
  type: int
stderr:
  description: Any errors returned by async_wrapper
  returned: always
  type: str
stdout:
  description: Any output returned by async_wrapper
  returned: always
  type: str

See also