Handle no status from ansible uri module

There are apparently cases where the ansible uri module won't have a
status item in its result dict. Check that status is there before
comparing against its value when doing network sanity checks.

Without this the following issue can occur:

2017-04-17 03:33:34.536 | localhost | FAILED! => {
    "failed": true,
    "msg": "The conditional check 'uri_result['status'] == 200' failed. The error was: error while evaluating conditional (uri_result['status'] == 200): 'dict object' has no attribute 'status'"
}

Change-Id: I5c848bfbb955b7201abcef71c2cbba2ec0644b1a
This commit is contained in:
Clark Boylan
2017-04-17 08:51:00 -07:00
parent ce56c6704e
commit 57ee9e3a13

View File

@@ -1,5 +1,6 @@
- name: Perform HTTP check
uri: url={{ url }}
register: uri_result
until: uri_result['status'] == 200
until: ('status' in uri_result and uri_result['status'] == 200)
changed_when: False
retries: "{{ HTTP_TIMES }}"