【发布时间】:2021-11-15 17:49:26
【问题描述】:
我正在尝试在 ansible 中处理 http 状态代码的错误。我的用例是检查状态代码 400(失败代码),它需要通过 2 个已知的错误条件。 就像内容在 400 响应中有特定的搜索字符串一样。 示例任务:
-name: create repo
uri:
url:
method: POST
body_format:json
.
.
status_code:
- 201
- 400
register: value
changed_when: value.status == 201
failed_when: value.status == 400 and
value.content|default() is not search ("found duplicate value")
上面的工作,但 期望另一个搜索字符串与或条件相同且 400 个类似。
-name: create repo
uri:
url:
method: POST
body_format:json
.
.
status_code:
- 201
- 400
register: value
changed_when: value.status == 201
failed_when: value.status == 400 and
( value.content|default() is not search ("found 1st duplicate value") or value.content|default() is not search ("found 2nd duplicate value") )
如何处理条件 2 or's with the 'and'..
【问题讨论】: