You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hetzner-ansible/roles/elastic/tasks/update_settings.yml

99 lines
2.8 KiB
YAML

---
### tags:
### update_config
### update_settings
### update_ilm_configuration
- name: "Wait for <https://{{ inventory_hostname }}:9200>"
ansible.builtin.uri:
url: "https://{{ inventory_hostname }}:9200"
user: "{{ elastic_admin_username }}"
password: "{{ elastic_admin_password }}"
ca_path: "{{ service_base_path }}/{{ elastic_id }}/certs/ca/ca.crt"
method: GET
status_code: 200
return_content: yes
register: elastic_stats
until: elastic_stats.status == 200
retries: 15
delay: 6
tags:
- update_config
- update_settings
- name: "Set VAR"
ansible.builtin.set_fact:
es_cluster_settings:
persistent:
cluster.max_shards_per_node: "{{ elastic_cluster_settings_max_shards }}"
tags:
- update_config
- update_settings
- name: "Set cluster config"
ansible.builtin.uri:
url: "https://localhost:9200/_cluster/settings"
method: PUT
ca_path: "{{ service_base_path }}/{{ elastic_id }}/certs/ca/ca.crt"
user: "{{ elastic_admin_username }}"
password: "{{ elastic_admin_password }}"
headers:
Content-Type: "application/json"
Accept: "application/json"
body: "{{ es_cluster_settings | to_json }}"
force_basic_auth: true
status_code: 200
when:
- inventory_hostname == groups['elastic'][0]
tags:
- update_config
- update_settings
- name: "Create/Update ILM Policies"
ansible.builtin.uri:
url: "https://localhost:9200/_ilm/policy/{{ configuration.name }}"
user: "{{ elastic_admin_username }}"
password: "{{ elastic_admin_password }}"
ca_path: "{{ service_base_path }}/{{ elastic_id }}/certs/ca/ca.crt"
method: PUT
headers:
Content-Type: "application/json"
Accept: "application/json"
body_format: json
body: "{{ lookup('template', configuration.strategy + '_policy.j2') }}"
force_basic_auth: true
status_code: [200]
when:
- inventory_hostname == groups['elastic'][0]
tags:
- update_config
- update_settings
- update_ilm_configuration
loop: "{{ ilm_configuration }}"
loop_control:
loop_var: configuration
- name: "Create/Update Index Templates"
ansible.builtin.uri:
url: "https://localhost:9200/_index_template/{{ configuration.template }}"
user: "{{ elastic_admin_username }}"
password: "{{ elastic_admin_password }}"
ca_path: "{{ service_base_path }}/{{ elastic_id }}/certs/ca/ca.crt"
method: PUT
headers:
Content-Type: "application/json"
Accept: "application/json"
body_format: json
body: "{{ lookup('template', configuration.strategy + '_template.j2') }}"
force_basic_auth: true
status_code: 200
when:
- inventory_hostname == groups['elastic'][0]
tags:
- update_config
- update_settings
- update_ilm_configuration
loop: "{{ ilm_configuration }}"
loop_control:
loop_var: configuration