28 lines
871 B
YAML
28 lines
871 B
YAML
---
|
|
|
|
- name: ensure templates dir is created
|
|
file:
|
|
path: /etc/elasticsearch/templates
|
|
state: directory
|
|
owner: "{{ es_user }}"
|
|
group: "{{ es_group }}"
|
|
|
|
- name: Copy templates to elasticsearch
|
|
copy: src={{ item }} dest=/etc/elasticsearch/templates owner={{ es_user }} group={{ es_group }}
|
|
register: load_templates
|
|
with_fileglob:
|
|
- "{{ es_templates_fileglob | default('') }}"
|
|
|
|
- name: Install templates
|
|
uri:
|
|
url: "http://{{es_api_host}}:{{es_api_port}}/_template/{{item | filename}}"
|
|
method: PUT
|
|
status_code: 200
|
|
user: "{{es_api_basic_auth_username | default(omit)}}"
|
|
password: "{{es_api_basic_auth_password | default(omit)}}"
|
|
body_format: json
|
|
body: "{{ lookup('file', item) }}"
|
|
when: load_templates.changed and es_start_service
|
|
with_fileglob:
|
|
- "{{ es_templates_fileglob | default('') }}"
|
|
run_once: True
|