
    Vh                    p    d dl mZ dZdZdZd dlZd dlZd dlmZ d dl	m
Z
 d dlmZ d	 Zed
k(  r e        yy)    )annotationsa}  
---
module: async_status
short_description: Obtain status of asynchronous task
description:
- This module gets the status of an asynchronous task.
- This module is also supported for Windows targets.
version_added: "0.5"
options:
  jid:
    description:
    - Job or task identifier
    type: str
    required: true
  mode:
    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
    choices: [ cleanup, status ]
    default: status
extends_documentation_fragment:
- action_common_attributes
- action_common_attributes.flow
attributes:
    action:
        support: full
    async:
        support: none
    check_mode:
        support: full
        version_added: '2.17'
    diff_mode:
        support: none
    bypass_host_loop:
        support: none
    platform:
        support: full
        platforms: posix, windows
seealso:
- ref: playbooks_async
  description: Detailed information on how to use asynchronous actions and polling.
author:
- Ansible Core Team
- Michael DeHaan
a  
---
- 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
a  
ansible_job_id:
  description: The asynchronous job id
  returned: success
  type: str
  sample: '360874038559.4169'
finished:
  description: Whether the asynchronous job has finished (V(1)) or not (V(0))
  returned: always
  type: int
  sample: 1
started:
  description: Whether the asynchronous job has started (V(1)) or not (V(0))
  returned: always
  type: int
  sample: 1
stdout:
  description: Any output returned by async_wrapper
  returned: always
  type: str
stderr:
  description: Any errors returned by async_wrapper
  returned: always
  type: str
erased:
  description: Path to erased job file
  returned: when file is erased
  type: str
N)AnsibleModule)	iteritems)	to_nativec                    t        t        t        dd      t        ddddg      t        dd            d	      } | j                  d
   }| j                  d   }| j                  d   }t        j                  j                  ||      }t        j                  j                  |      s| j                  d|dd       |dk(  r(t        j                  |       | j                  ||       d }	 t        |      5 }t        j                  |j                               }d d d        d|vrd|d<   ||d<   n	d|vrd|d<   t        |      D ci c]  \  }}t!        |      | }}} | j                  di | y # 1 sw Y   [xY w# t        $ r4 |s| j                  ||dd       n| j                  ||d|z  dd       Y w xY wc c}}w )NstrT)typerequiredstatuscleanup)r	   defaultchoicespath)jidmode
_async_dir)argument_specsupports_check_moder   r   r   zcould not find job   )msgansible_job_idstartedfinished)r   erasedr   )results_filer   r   r   zCould not parse job output: %s)r   r   r   r   r   r   r   r    )r   dictparamsosr   joinexists	fail_jsonunlink	exit_jsonopenjsonloadsread	Exceptionr   r   )	moduler   r   	async_dirlog_pathdatafkvs	            L/home/dcms/DCMS/lib/python3.12/site-packages/ansible/modules/async_status.pymainr2   v   s   %$/5(Y<QR$7	
 !F == D
--
Cl+I ww||Is+H77>>(#1#q[\]y
		(H= D	a(^ 	(q::affh'D	( Z!$	4	Z )2$81IaL!O8D8Ft'	( 	( a(3PQ\]^Ch!AD!HRS^_  aa 9s0   /F :$E8F G8F=F :G G__main__)
__future__r   DOCUMENTATIONEXAMPLESRETURNr&   r   ansible.module_utils.basicr   ansible.module_utils.sixr   +ansible.module_utils.common.text.convertersr   r2   __name__r       r1   <module>r=      sK    #-^0
<  	 4 . A3l zF r<   