### SUMMARY
I need to call one api to get async result, the api result is like

{ "resultCode": 0, "resultInfo": "cutover is running", "taskStatus": "21" }

when taskStatus is 21 means the tasks is running, I should wait and contnue 
to get the result until the taskStatus becomes 20 that means success, but 
when the taskStatus is 22 means the api fails, and I should break the loop 
call. But I found that I cann't use fail_when with uri module at the same 
time. So how can I do to continue checking the result for 30min when the 
result is running and quit when the result is fail?

Here is my task:

- uri:
    url: "http://10.xx.xx.xx/api/task/verify/";
    follow_redirects: all
    method: GET
    return_content: yes
    status_code: 200
    timeout: 300
    body: '{"hostname": "{{check_box.hostname}}"}' #my variable , but doesn't 
matter
    body_format: json
    headers:
      Content-Type: "application/json"
  register: current_status
  until:
    - current_status.json.taskStatus == 20
  retries: 180 # try 30 min
  delay: 10

ISSUE TYPE
   
   - Documentation Report

COMPONENT NAMEANSIBLE VERSION

ansible 2.9.10

CONFIGURATION

OS / ENVIRONMENT

CentOS Linux release 7.6.1810 (Core)

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/3700002c-9e72-4483-9ae0-af40f19293bao%40googlegroups.com.

Reply via email to