30 lines
884 B
YAML
30 lines
884 B
YAML
---
|
||
|
||
- name: ensure templates dir is created
|
||
file:
|
||
path: "{{ es_conf_dir }}/templates"
|
||
state: directory
|
||
owner: root
|
||
group: "{{ es_group }}"
|
||
mode: 2750
|
||
|
||
- name: Copy templates to elasticsearch
|
||
copy: src={{ item }} dest={{ es_conf_dir }}/templates owner=root group={{ es_group }} mode=0660
|
||
register: load_templates
|
||
with_fileglob:
|
||
- "{{ es_templates_fileglob | default('') }}"
|
||
|
||
- name: Install templates
|
||
uri:
|
||
url: "{{ es_api_uri }}/_template/{{item | filename}}"
|
||
method: PUT
|
||
status_code: 200
|
||
user: "{{es_api_basic_auth_username | default(omit)}}"
|
||
password: "{{es_api_basic_auth_password | default(omit)}}"
|
||
force_basic_auth: yes
|
||
body_format: json
|
||
body: "{{ lookup('file', item) }}"
|
||
when: load_templates.changed and es_start_service
|
||
with_fileglob:
|
||
- "{{ es_templates_fileglob | default('') }}"
|
||
run_once: True
|