Add state for updating Elasticsearch index templates

To prevent index template from constant or accidential update
add separate salt state to explicit use in order to update.

To use run:
  salt -C 'I@elasticsearch:client' state.sls elasticsearch.client.update_index_templates

Change-Id: I19aca3c6901f79ac22457a30aada0904057de5cc
Closes-Bug: PROD-17954
diff --git a/README.rst b/README.rst
index eb8a67b..a117a0b 100644
--- a/README.rst
+++ b/README.rst
@@ -192,6 +192,15 @@
                           type: keyword
                           ignore_above: 256
 
+Upgrade operations
+------------------
+
+Default elasticsearch client state can only create index temlates. To update exisiting ones according to pillar dedicated state should be run explicitly:
+
+.. code-block:: bash
+
+    salt -C 'I@elasticsearch:client' state.sls elasticsearch.client.update_index_templates
+
 Read more
 =========
 
diff --git a/elasticsearch/client/update_index_templates.sls b/elasticsearch/client/update_index_templates.sls
new file mode 100644
index 0000000..88c8e64
--- /dev/null
+++ b/elasticsearch/client/update_index_templates.sls
@@ -0,0 +1,31 @@
+{%- from "elasticsearch/map.jinja" import client with context %}
+{%- if client.get('enabled', False) %}
+
+include:
+  - elasticsearch.client.service
+
+{%- for index_name, index in client.get('index', {}).iteritems() %}
+elasticsearch_index_template_upgrade_{{ index_name }}:
+
+  {%- if index.get('enabled', False) %}
+
+    {%- if index.definition is defined %}
+      {% set definition = index.definition %}
+    {%- endif %}
+    {%- if index.template is defined %}
+      {%- import_json index.template as definition %}
+    {%- endif %}
+
+    {%- if definition is defined %}
+  module.run:
+  - name: elasticsearch.index_template_create
+  - m_name: {{ index_name }}
+  - body: '{{ definition|json }}'
+  - require:
+    - pkg: elasticsearch_client_packages
+    {%- endif %}
+
+  {%- endif %}
+
+{%- endfor %}
+{%- endif %}