--- - file: path=/etc/elasticsearch/templates state=directory owner={{ es_user }} group={{ es_group }} - name: Copy default templates to elasticsearch copy: src=templates dest=/etc/elasticsearch/ owner={{ es_user }} group={{ es_group }} when: es_templates_fileglob is not defined - name: Copy templates to elasticsearch copy: src={{ item }} dest=/etc/elasticsearch/templates owner={{ es_user }} group={{ es_group }} when: es_templates_fileglob is defined with_fileglob: - "{{ es_templates_fileglob }}" - set_fact: http_port=9200 tags: - always - set_fact: http_port={{es_config['http.port']}} when: es_config['http.port'] is defined tags: - always - 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 }}"