|
1 | 1 | --- |
2 | 2 | # Ingest data generated by gen_synth_loki_data.yml to Loki |
3 | 3 |
|
4 | | -- name: "TEST Push data to Loki" |
5 | | - ansible.builtin.uri: |
6 | | - ## loki_push_url will be used in future role developement |
7 | | - url: "{{ loki_push_url }}" |
8 | | - method: POST |
9 | | - src: "{{ cloudkitty_data_file }}" |
10 | | - body_format: json |
11 | | - client_cert: "{{ cert_dir }}/tls.crt" |
12 | | - client_key: "{{ cert_dir }}/tls.key" |
13 | | - validate_certs: false |
14 | | - status_code: 204 |
15 | | - return_content: true |
16 | | - register: loki_response |
17 | | - ignore_errors: true |
18 | | - failed_when: loki_response.status != 204 |
| 4 | +- name: "Push data to Loki {{ scenario_name }}" |
| 5 | + block: |
| 6 | + - name: "POST data to Loki" |
| 7 | + ansible.builtin.uri: |
| 8 | + # loki_push_url is configured in setup_loki_env.yml |
| 9 | + url: "{{ loki_push_url }}" |
| 10 | + method: POST |
| 11 | + src: "{{ cloudkitty_data_file }}" |
| 12 | + body_format: json |
| 13 | + client_cert: "{{ cert_dir }}/tls.crt" |
| 14 | + client_key: "{{ cert_dir }}/tls.key" |
| 15 | + # Note: ca_path not required with validate_certs: false, but included for consistency with retrieve_loki_data.yml |
| 16 | + ca_path: "{{ cert_dir }}/ca.crt" |
| 17 | + validate_certs: false |
| 18 | + status_code: 204 |
| 19 | + return_content: true |
| 20 | + register: loki_response |
19 | 21 |
|
20 | | -- name: "Ingest Status Message" |
21 | | - ansible.builtin.debug: |
22 | | - msg: "Ingestion Successful" |
23 | | - when: loki_response.status | default(0) == 204 |
| 22 | + - name: "Ingest Status Message" |
| 23 | + ansible.builtin.debug: |
| 24 | + msg: "Ingestion Successful for {{ scenario_name }}" |
| 25 | + |
| 26 | + rescue: |
| 27 | + - name: "IngestionFailed" |
| 28 | + ansible.builtin.fail: |
| 29 | + msg: |
| 30 | + - "Scenario: {{ scenario_name }}" |
| 31 | + - "Status: {{ loki_response.status | default('Unknown') }}" |
| 32 | + - "Body: {{ loki_response.content | default('No Content') }}" |
| 33 | + - "Message: {{ loki_response.msg | default('Request failed') }}" |
0 commit comments