gpt4 book ai didi

ansible - Ansible uri 模块中的多个 status_code

转载 作者:行者123 更新时间:2023-12-04 17:07:38 27 4
gpt4 key购买 nike

我正在使用 ansible uri 模块发出 POST 请求。该请求返回状态 201 或 208,并且应考虑这两个状态代码以使任务通过。如何指定多个 status_code 值或如何实现?

  - uri:
url: "http://mywebsite.org/api/hooks/release/builtin/"
method: POST
HEADER_Content-Type: "application/json"
body: '{"version": "6.2.10"}'
body_format: json
status_code: 208
register: result
failed_when: status_code != 201 or status_code != 208

最佳答案

根据 uri module manual :

status_code A valid, numeric, HTTP status code that signifies success of the request. Can also be comma separated list of status codes.



所以:
- uri:
url: "http://mywebsite.org/api/hooks/release/builtin/"
method: POST
HEADER_Content-Type: "application/json"
body: '{"version": "6.2.10"}'
body_format: json
status_code: 201, 208
register: result

关于ansible - Ansible uri 模块中的多个 status_code,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41482268/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com