Ansible 不接受客户失败模块
Ansible is not accepting customer fail module
- name: "Waiting for URL to come up."
uri:
url: "{{ url }}/libs/granite/core/content/login.html"
status_code: 200
register: result
until: result.status == 200
retries: 10
delay: 10
fail:
msg: "Service was not available after 10 minutes. Files were installed except for the ones that required AEM to be available"
我正在添加失败消息,这样当任务失败时我们将得到有意义的输出。
但是我收到一个错误:
line 3, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: \"Waiting for URL to come up.\"\n ^ here\n"}[0
我查看了文档,这似乎是正确的做法。我错过了什么?
如果您查看 documentation for the uri
module,您会
请注意,没有 fail
参数。然而,有一个单独的
fail
module。如果你想使用它,你需要
重写你的 uri
任务,这样它就不会导致 Ansible 失败,但是
而是记录任务结果,以便您可以在后续中使用它
fail
行动。
- name: "Waiting for URL to come up."
uri:
url: "{{ url }}/libs/granite/core/content/login.html"
status_code: 200
until: result.status == 200
retries: 10
delay: 10
register: uri_result
ignore_errors: true
- name: fail with custom message
when: uri_result is failed
fail:
msg: >-
Service was not available after 10 minutes. Files
were installed except for the ones that required AEM
to be available.
- name: "Waiting for URL to come up."
uri:
url: "{{ url }}/libs/granite/core/content/login.html"
status_code: 200
register: result
until: result.status == 200
retries: 10
delay: 10
fail:
msg: "Service was not available after 10 minutes. Files were installed except for the ones that required AEM to be available"
我正在添加失败消息,这样当任务失败时我们将得到有意义的输出。 但是我收到一个错误:
line 3, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: \"Waiting for URL to come up.\"\n ^ here\n"}[0
我查看了文档,这似乎是正确的做法。我错过了什么?
如果您查看 documentation for the uri
module,您会
请注意,没有 fail
参数。然而,有一个单独的
fail
module。如果你想使用它,你需要
重写你的 uri
任务,这样它就不会导致 Ansible 失败,但是
而是记录任务结果,以便您可以在后续中使用它
fail
行动。
- name: "Waiting for URL to come up."
uri:
url: "{{ url }}/libs/granite/core/content/login.html"
status_code: 200
until: result.status == 200
retries: 10
delay: 10
register: uri_result
ignore_errors: true
- name: fail with custom message
when: uri_result is failed
fail:
msg: >-
Service was not available after 10 minutes. Files
were installed except for the ones that required AEM
to be available.