我正在进行 REST 调用,并希望在继续之前检查我的请求是否已完成。在响应中,我得到一个“PENDING”或“IN_PROGRESS”作为 request_status。我想等到我得到“完成”或“失败”。为此,我想等待“PENDING”或“IN_PROGRESS”
我尝试了很多变化但未能成功,最后一次尝试如下:
- name: Wait for the cluster deployment (this will take a while)
uri:
url: http://localhost:8080/api/v1/clusters/{{ cluster_name }}/requests/1
method: GET
user: admin
password: admin
HEADER_X-Requested-By: Ansible
force_basic_auth: yes
status_code: 200, 201, 202
return_content: yes
register: response
until: "'{{ (response.content | from_json).Requests.request_status }}' != 'PENDING' AND '{{ (response.content | from_json).Requests.request_status }}' != 'IN_PROGRESS'"
retries: 3
delay: 5
错误是:
“条件检查 ''{{ (response.content | from_json).Requests.request_status }}' != 'PENDING' AND '{{ (response.content | from_json).Requests.request_status }}' != 'IN_PROGRESS' '失败。错误是:模板化字符串时出现模板错误:预期标记'语句块结束',得到'AND'。字符串:{% if 'COMPLETED' != 'PENDING' AND 'COMPLETED' != 'IN_PROGRESS' % } 真 {% else %} 假 {% endif %}"
所以,我的问题是如何在 Ansible 的 do-until 循环中指定多个条件?