-
-
Save acardak/7d67762c98e2d40e3ac6f795a6699638 to your computer and use it in GitHub Desktop.
Revisions
-
ParagDoke revised this gist
Sep 12, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -25,5 +25,5 @@ msg: "{{ debug_msg_prefix | default('') }}{{ response.json | json_query(json_query_to_build_debug_msg) }}{{ debug_msg_suffix | default('') }}" when: display_debug_msg_for_each_attempt | bool and json_query_to_build_debug_msg is defined - include_tasks: includes/status-poller.yml when: poll_condition -
ParagDoke created this gist
Sep 12, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ --- - name: test hosts: localhost connection: local tasks: - name: Invoke poller vars: url: http://localhost:8000/abc.json validate_certs: yes poll_interval: 10 poll_condition: '"failed" not in response.content and response.json.status=="running"' fail_condition: '"failed" in response.content' max_poll_attempts: 5 display_debug_msg_for_each_attempt: yes json_query_to_build_debug_msg: "tasks[?status=='running'] | [0].name" debug_msg_prefix: 'Prefix:' debug_msg_suffix: '' include_tasks: status-poller.yml This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ --- - set_fact: attempts: "{{ attempts | default(0) | int + 1 }}" - fail: msg="Number of attempts exceeded {{ max_poll_attempts }}" when: (attempts | int) > (max_poll_attempts | int) - debug: msg: "Attempt: {{ attempts }}/{{ max_poll_attempts }}" - pause: seconds: "{{ poll_interval }}" no_log: true - name: Fetch status afresh no_log: true uri: url: "{{ url }}" return_content: yes validate_certs: "{{ validate_certs }}" register: response failed_when: fail_condition - debug: msg: "{{ debug_msg_prefix | default('') }}{{ response.json | json_query(json_query_to_build_debug_msg) }}{{ debug_msg_suffix | default('') }}" when: display_debug_msg_for_each_attempt | bool and json_query_to_build_debug_msg is defined - include: includes/status-poller.yml when: poll_condition