--- - 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 }} notify: load-templates 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 notify: load-templates with_fileglob: - "{{ es_templates_fileglob }}"