Newer
Older
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
53
54
55
56
57
58
59
60
61
62
63
64
65
---
- name: Wait for OpenSearch to become ready
become: true
kolla_toolbox:
container_engine: "{{ kolla_container_engine }}"
module_name: uri
module_args:
url: "{{ opensearch_internal_endpoint }}/_cluster/stats"
status_code: 200
register: result
until: result.get('status') == 200
retries: 30
delay: 2
run_once: true
- name: Check if a log retention policy exists
become: true
kolla_toolbox:
container_engine: "{{ kolla_container_engine }}"
module_name: uri
module_args:
url: "{{ opensearch_internal_endpoint }}/_plugins/_ism/policies/retention"
method: GET
status_code: 200, 404
return_content: yes
register: opensearch_retention_policy_check
delegate_to: "{{ groups['opensearch'][0] }}"
run_once: true
- name: Create new log retention policy
become: true
kolla_toolbox:
container_engine: "{{ kolla_container_engine }}"
module_name: uri
module_args:
url: "{{ opensearch_internal_endpoint }}/_plugins/_ism/policies/retention"
method: PUT
status_code: 201
return_content: yes
body: "{{ opensearch_retention_policy | from_yaml | to_json }}"
body_format: json
register: opensearch_retention_policy_create
delegate_to: "{{ groups['opensearch'][0] }}"
run_once: true
changed_when: opensearch_retention_policy_create.status == 201
when: opensearch_retention_policy_check.status == 404
- name: Apply retention policy to existing indicies
become: true
vars:
opensearch_set_policy_body: {"policy_id": "retention"}
kolla_toolbox:
container_engine: "{{ kolla_container_engine }}"
module_name: uri
module_args:
url: "{{ opensearch_internal_endpoint }}/_plugins/_ism/add/{{ opensearch_log_index_prefix }}-*"
method: POST
status_code: 200
return_content: yes
body: "{{ opensearch_set_policy_body | to_json }}"
body_format: json
delegate_to: "{{ groups['opensearch'][0] }}"
run_once: true
changed_when: opensearch_retention_policy_create.status == 201
when: opensearch_retention_policy_check.status == 404