ansible.windows.async_status (2.3.0) — module

Obtain status of asynchronous task

Authors: Ansible Core Team

Install collection

Install with ansible-galaxy collection install ansible.windows:==2.3.0


Add to requirements.yml

  collections:
    - name: ansible.windows
      version: 2.3.0

Description

This module gets the status of an asynchronous task.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Asynchronous yum task
  ansible.windows.win_command: my.exe
  async: 1000
  poll: 0
  register: long_cmd
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Wait for asynchronous job to end
  ansible.builtin.async_status:
    jid: '{{ long_cmd.ansible_job_id }}'
  register: job_result
  until: job_result.finished
  retries: 100
  delay: 10

Inputs

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

mode:
    choices:
    - cleanup
    - status
    default: status
    description:
    - If C(status), obtain the status.
    - If C(cleanup), clean up the async job cache (by default in C(~/.ansible_async/))
      for the specified job I(jid).
    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 (C(1)) or not (C(0))
  returned: always
  sample: 1
  type: int
started:
  description: Whether the asynchronous job has started (C(1)) or not (C(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