ansible-role-elasticsearch/tasks/elasticsearch-templates.yml
Jonathan Strootman d36f1dd497 Added with_fileglob loop to script and template
This allows the user to set the `es_template_fileglob` or
`es_scripts_fileglob` variables in order to specify a directory of index
templates or scripts.

Issue #57
2016-03-09 16:55:39 -07:00

21 lines
758 B
YAML

---
- name: Copy templates to elasticsearch
copy: src={{ item }} dest=/etc/elasticsearch/ owner={{ es_user }} group={{ es_group }}
with_fileglob: es_templates_fileglob | default("templates")
- set_fact: http_port=9200
- set_fact: http_port={{es_config['http.port']}}
when: es_config['http.port'] is defined
- name: Wait for elasticsearch to startup
wait_for: port={{http_port}} delay=10
- name: Get template files
shell: find . -maxdepth 1 -type f | sed "s#\./##" | sed "s/.json//" chdir=/etc/elasticsearch/templates
register: resultstemplate
- name: Install template(s)
command: "curl -sL -XPUT http://localhost:{{http_port}}/_template/{{item}} -d @/etc/elasticsearch/templates/{{item}}.json"
with_items: resultstemplate.stdout_lines