ansible-role-elasticsearch/tasks/data.yml

47 lines
1.5 KiB
YAML

---
- name: Init elastic password
elasticsearch_init_password:
api_user: "{{ elasticsearch_api_user }}"
api_password: "{{ elasticsearch_password }}"
run_once: true
tags: elasticsearch
- name: Manage users
elasticsearch_user:
name: "{{ item.key }}"
password: "{{ item.value.password }}"
roles: "{{ item.value.roles | default(omit) }}"
api_user: "{{ elasticsearch_api_user }}"
api_password: "{{ elasticsearch_password }}"
state: "{{ item.value.state | default('present') }}"
loop: "{{ elasticsearch_users | dict2items }}"
loop_control:
label: "{{ item.key }}"
run_once: true
tags: elasticsearch
- name: Copy ilm policies
elasticsearch_ilm_policy:
name: "{{ item.key }}"
phases: "{{ item.value | default({}) }}"
api_user: "{{ elasticsearch_api_user }}"
api_password: "{{ elasticsearch_password }}"
loop: "{{ elasticsearch_ilm_policies | dict2items }}"
loop_control:
label: "{{ item.key }}"
run_once: true
tags: elasticsearch
- name: Copy index templates
elasticsearch_template:
name: "{{ item.key }}"
index_patterns: "{{ item.value.index_patterns }}"
settings: "{{ item.value.settings | default({}) }}"
mappings: "{{ item.value.mappings | default({}) }}"
api_user: "{{ elasticsearch_api_user }}"
api_password: "{{ elasticsearch_password }}"
loop: "{{ elasticsearch_index_templates | dict2items }}"
loop_control:
label: "{{ item.key }}"
run_once: true
tags: elasticsearch