-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathflush_loki_data.yml
More file actions
52 lines (46 loc) · 1.58 KB
/
flush_loki_data.yml
File metadata and controls
52 lines (46 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
---
# Flush Loki Ingester Memory to Storage
- name: Flush Execution inside openstack CLI
block:
# create dir
- name: Create directory inside openstack CLI
ansible.builtin.command:
cmd: "oc exec -n {{ namespace }} {{ openstackpod }} -- mkdir -p {{ remote_cert_dir }}"
changed_when: false
# copy all certs
- name: Copy certificates to openstack CLI
ansible.builtin.command:
cmd: "oc cp {{ local_cert_dir }}/. {{ namespace }}/{{ openstackpod }}:{{ remote_cert_dir }}/"
changed_when: true
# flush loki
- name: Trigger Flush
ansible.builtin.command:
cmd: >
oc exec -n {{ namespace }} {{ openstackpod }} --
curl -v -X POST {{ ingester_flush_url }}
--cert {{ remote_cert_dir }}/tls.crt
--key {{ remote_cert_dir }}/tls.key
--cacert {{ remote_cert_dir }}/service-ca.crt
register: flush_response
changed_when: true
failed_when: flush_response.rc != 0
# Status
- name: Verify Flush Status
ansible.builtin.assert:
that:
- "'204' in flush_response.stderr or '200' in flush_response.stderr"
fail_msg: "Flush failed"
success_msg: "Ingester Memory Flushed successfully"
rescue:
- name: Debug Failure Output
ansible.builtin.debug:
msg:
- "Failure"
- "Stdout: {{ flush_response.stdout }}"
- "Stderr: {{ flush_response.stderr }}"
always:
# Cleanup
- name: Cleanup local certificates
ansible.builtin.file:
path: "{{ local_cert_dir }}"
state: absent