diff --git a/ansible/inventory/env/group_vars/all.yml b/ansible/inventory/env/group_vars/all.yml
index 375d89c2b1cc206d8175ff4e6f57068c34384285..cf464e69bb9dd6a9719c57c05c601b9b4018ebff 100644
--- a/ansible/inventory/env/group_vars/all.yml
+++ b/ansible/inventory/env/group_vars/all.yml
@@ -553,7 +553,7 @@ backup_azure_storage_access_key: "{{core_vault_azure_storage_secret}}"
 app_es_snapshot_host: "{{ groups['es'][0] }}"
 app_snapshot_base_path: applicationelasticsearch
 
-sunbird-es-host: "{{ groups['es'][0] }}"
+sunbird_es_host: "{{ groups['es'][0] }}"
 
 #log es backup
 log_es_snapshot_host: "{{ groups['log-es'][0] }}"
diff --git a/ansible/provision.yml b/ansible/provision.yml
index 6367cc6710391e81b5ecb110d8bcad4709f81b18..0546293a3d4d0fdf1f6917e1a3f342bb95c9a9db 100644
--- a/ansible/provision.yml
+++ b/ansible/provision.yml
@@ -19,7 +19,7 @@
         es_instance_name: "{% for servername in play_hosts %}{% if inventory_hostname==servername %}es-{{ loop.index }}{% endif %}{% endfor %}"
   roles:
     - openjdk
-    - { role: es6, 
+    - { role: es6,
         es_config: {
           cluster.name: "{{ app_es_etc_cluster_name }}",
           discovery.zen.ping.unicast.hosts: "{{ groups['es'] }}",
@@ -38,6 +38,7 @@
     - es
 
 - hosts: log-es
+  gather_facts: true
   become: yes
   vars_files:
     - ['{{inventory_dir}}/secrets.yml', 'secrets/{{env}}.yml']
diff --git a/ansible/roles/curl_es_command/templates/curl_commands.j2 b/ansible/roles/curl_es_command/templates/curl_commands.j2
index 04a11dd7d49ea0d2f3ec68a60c49396ee22ce886..d0de39f1f270f8aa34bf91bf9a062f7217001e8a 100755
--- a/ansible/roles/curl_es_command/templates/curl_commands.j2
+++ b/ansible/roles/curl_es_command/templates/curl_commands.j2
@@ -2,32 +2,32 @@
 
 
 
-curl -XPUT '{{sunbird-es-host}}:9200/searchindex?pretty' -H 'Content-Type: application/json' -d'
+curl -XPUT '{{sunbird_es_host}}:9200/searchindex?pretty' -H 'Content-Type: application/json' -d'
 {
     "settings" : {"analysis": {"analyzer": {"cs_index_analyzer": {"type": "custom","tokenizer": "standard","filter": ["lowercase","mynGram"]},"cs_search_analyzer": {"type": "custom","tokenizer": "standard","filter": ["lowercase","standard"]},"keylower": {"type": "custom","tokenizer": "keyword","filter": "lowercase"}},"filter": {"mynGram": {"type": "ngram","min_gram": 1,"max_gram": 20,"token_chars": ["letter", "digit","whitespace","punctuation","symbol"]} }}}
 }'
 
-curl -XPUT '{{sunbird-es-host}}:9200/searchindex/user/_mapping?pretty' -H 'Content-Type: application/json' -d'
+curl -XPUT '{{sunbird_es_host}}:9200/searchindex/user/_mapping?pretty' -H 'Content-Type: application/json' -d'
 {
     "user" : {  "dynamic_templates": [ {"longs": {"match_mapping_type": "long", "mapping": {"type": "long", "fields": { "raw": {"type": "long"  } }}}},{"booleans": {"match_mapping_type": "boolean", "mapping": {"type": "boolean", "fields": { "raw": { "type": "boolean" }} }}},{"doubles": {"match_mapping_type": "double","mapping": {"type": "double","fields":{"raw": { "type": "double" } }}}},{ "dates": {"match_mapping_type": "date", "mapping": { "type": "date","fields": {"raw": { "type": "date" } } }}},{"strings": {"match_mapping_type": "string","mapping": {"type": "text","fielddata": true,"copy_to": "all_fields","analyzer": "cs_index_analyzer","search_analyzer": "cs_search_analyzer","fields": {"raw": {"type": "text","fielddata": true,"analyzer": "keylower"}}}}}],"properties": {"all_fields": {"type": "text","analyzer": "cs_index_analyzer","search_analyzer": "cs_search_analyzer","fields": { "raw": { "type": "text","analyzer": "keylower" } }} }}
 }'
 
-curl -XPUT '{{sunbird-es-host}}:9200/searchindex/org/_mapping?pretty' -H 'Content-Type: application/json' -d'
+curl -XPUT '{{sunbird_es_host}}:9200/searchindex/org/_mapping?pretty' -H 'Content-Type: application/json' -d'
 {
     "org" : {  "dynamic_templates": [ {"longs": {"match_mapping_type": "long", "mapping": {"type": "long", "fields": { "raw": {"type": "long"  } }}}},{"booleans": {"match_mapping_type": "boolean", "mapping": {"type": "boolean", "fields": { "raw": { "type": "boolean" }} }}},{"doubles": {"match_mapping_type": "double","mapping": {"type": "double","fields":{"raw": { "type": "double" } }}}},{ "dates": {"match_mapping_type": "date", "mapping": { "type": "date","fields": {"raw": { "type": "date" } } }}},{"strings": {"match_mapping_type": "string","mapping": {"type": "text","fielddata": true,"copy_to": "all_fields","analyzer": "cs_index_analyzer","search_analyzer": "cs_search_analyzer","fields": {"raw": {"type": "text","fielddata": true,"analyzer": "keylower"}}}}}],"properties": {"all_fields": {"type": "text","analyzer": "cs_index_analyzer","search_analyzer": "cs_search_analyzer","fields": { "raw": { "type": "text","analyzer": "keylower" } }} }}
 }'
 
-curl -XPUT '{{sunbird-es-host}}:9200/searchindex/course/_mapping?pretty' -H 'Content-Type: application/json' -d'
+curl -XPUT '{{sunbird_es_host}}:9200/searchindex/course/_mapping?pretty' -H 'Content-Type: application/json' -d'
 {
     "course" : {  "dynamic_templates": [ {"longs": {"match_mapping_type": "long", "mapping": {"type": "long", "fields": { "raw": {"type": "long"  } }}}},{"booleans": {"match_mapping_type": "boolean", "mapping": {"type": "boolean", "fields": { "raw": { "type": "boolean" }} }}},{"doubles": {"match_mapping_type": "double","mapping": {"type": "double","fields":{"raw": { "type": "double" } }}}},{ "dates": {"match_mapping_type": "date", "mapping": { "type": "date","fields": {"raw": { "type": "date" } } }}},{"strings": {"match_mapping_type": "string","mapping": {"type": "text","fielddata": true,"copy_to": "all_fields","analyzer": "cs_index_analyzer","search_analyzer": "cs_search_analyzer","fields": {"raw": {"type": "text","fielddata": true,"analyzer": "keylower"}}}}}],"properties": {"all_fields": {"type": "text","analyzer": "cs_index_analyzer","search_analyzer": "cs_search_analyzer","fields": { "raw": { "type": "text","analyzer": "keylower" } }} }}
 }'
 
-curl -XPUT '{{sunbird-es-host}}:9200/searchindex/usercourses/_mapping?pretty' -H 'Content-Type: application/json' -d'
+curl -XPUT '{{sunbird_es_host}}:9200/searchindex/usercourses/_mapping?pretty' -H 'Content-Type: application/json' -d'
 {
     "usercourses" : {  "dynamic_templates": [ {"longs": {"match_mapping_type": "long", "mapping": {"type": "long", "fields": { "raw": {"type": "long"  } }}}},{"booleans": {"match_mapping_type": "boolean", "mapping": {"type": "boolean", "fields": { "raw": { "type": "boolean" }} }}},{"doubles": {"match_mapping_type": "double","mapping": {"type": "double","fields":{"raw": { "type": "double" } }}}},{ "dates": {"match_mapping_type": "date", "mapping": { "type": "date","fields": {"raw": { "type": "date" } } }}},{"strings": {"match_mapping_type": "string","mapping": {"type": "text","fielddata": true,"copy_to": "all_fields","analyzer": "cs_index_analyzer","search_analyzer": "cs_search_analyzer","fields": {"raw": {"type": "text","fielddata": true,"analyzer": "keylower"}}}}}],"properties": {"all_fields": {"type": "text","analyzer": "cs_index_analyzer","search_analyzer": "cs_search_analyzer","fields": { "raw": { "type": "text","analyzer": "keylower" } }} }}
 }'    
 
-curl -XPUT '{{sunbird-es-host}}:9200/searchindex/cbatch/_mapping?pretty' \
+curl -XPUT '{{sunbird_es_host}}:9200/searchindex/cbatch/_mapping?pretty' \
   -H 'content-type: application/json' \
   -d '{"dynamic":false,"properties":{"all_fields":{"type":"text","fields":{"raw":{"type":"text","analyzer":"keylower"}},"analyzer":"cs_index_analyzer","search_analyzer":"cs_search_analyzer"},"countDecrementDate":{"type":"text","fields":{"raw":{"type":"text","analyzer":"keylower","fielddata":true}},"copy_to":["all_fields"],"analyzer":"cs_index_analyzer","search_analyzer":"cs_search_analyzer","fielddata":true},"countDecrementStatus":{"type":"boolean","fields":{"raw":{"type":"boolean"}}},"countIncrementDate":{"type":"text","fields":{"raw":{"type":"text","analyzer":"keylower","fielddata":true}},"copy_to":["all_fields"],"analyzer":"cs_index_analyzer","search_analyzer":"cs_search_analyzer","fielddata":true},"countIncrementStatus":{"type":"boolean","fields":{"raw":{"type":"boolean"}}},"courseCreator":{"type":"text","fields":{"raw":{"type":"text","analyzer":"keylower","fielddata":true}},"copy_to":["all_fields"],"analyzer":"cs_index_analyzer","search_analyzer":"cs_search_analyzer","fielddata":true},"courseId":{"type":"text","fields":{"raw":{"type":"text","analyzer":"keylower","fielddata":true}},"copy_to":["all_fields"],"analyzer":"cs_index_analyzer","search_analyzer":"cs_search_analyzer","fielddata":true},"batchId":{"type":"text","fields":{"raw":{"type":"text","analyzer":"keylower","fielddata":true}},"copy_to":["all_fields"],"analyzer":"cs_index_analyzer","search_analyzer":"cs_search_analyzer","fielddata":true},"createdBy":{"type":"text","fields":{"raw":{"type":"text","analyzer":"keylower","fielddata":true}},"copy_to":["all_fields"],"analyzer":"cs_index_analyzer","search_analyzer":"cs_search_analyzer","fielddata":true},"createdDate":{"type":"text","fields":{"raw":{"type":"text","analyzer":"keylower","fielddata":true}},"copy_to":["all_fields"],"analyzer":"cs_index_analyzer","search_analyzer":"cs_search_analyzer","fielddata":true},"createdFor":{"type":"text","fields":{"raw":{"type":"text","analyzer":"keylower","fielddata":true}},"copy_to":["all_fields"],"analyzer":"cs_index_analyzer","search_analyzer":"cs_search_analyzer","fielddata":true},"description":{"type":"text","fields":{"raw":{"type":"text","analyzer":"keylower","fielddata":true}},"copy_to":["all_fields"],"analyzer":"cs_index_analyzer","search_analyzer":"cs_search_analyzer","fielddata":true},"endDate":{"type":"date","fields":{"raw":{"type":"date"}}},"enrollmentType":{"type":"text","fields":{"raw":{"type":"text","analyzer":"keylower","fielddata":true}},"copy_to":["all_fields"],"analyzer":"cs_index_analyzer","search_analyzer":"cs_search_analyzer","fielddata":true},"hashTagId":{"type":"text","fields":{"raw":{"type":"text","analyzer":"keylower","fielddata":true}},"copy_to":["all_fields"],"analyzer":"cs_index_analyzer","search_analyzer":"cs_search_analyzer","fielddata":true},"id":{"type":"text","fields":{"raw":{"type":"text","analyzer":"keylower","fielddata":true}},"copy_to":["all_fields"],"analyzer":"cs_index_analyzer","search_analyzer":"cs_search_analyzer","fielddata":true},"identifier":{"type":"text","fields":{"raw":{"type":"text","analyzer":"keylower","fielddata":true}},"copy_to":["all_fields"],"analyzer":"cs_index_analyzer","search_analyzer":"cs_search_analyzer","fielddata":true},"mentors":{"type":"text","fields":{"raw":{"type":"text","analyzer":"keylower","fielddata":true}},"copy_to":["all_fields"],"analyzer":"cs_index_analyzer","search_analyzer":"cs_search_analyzer","fielddata":true},"name":{"type":"text","fields":{"raw":{"type":"text","analyzer":"keylower","fielddata":true}},"copy_to":["all_fields"],"analyzer":"cs_index_analyzer","search_analyzer":"cs_search_analyzer","fielddata":true},"startDate":{"type":"date","fields":{"raw":{"type":"date"}}},"status":{"type":"long","fields":{"raw":{"type":"long"}}},"updatedDate":{"type":"text","fields":{"raw":{"type":"text","analyzer":"keylower","fielddata":true}},"copy_to":["all_fields"],"analyzer":"cs_index_analyzer","search_analyzer":"cs_search_analyzer","fielddata":true}}}'
 
diff --git a/ansible/roles/elasticsearch_old/defaults/main.yml b/ansible/roles/elasticsearch_old/defaults/main.yml
index d33c97d2bed8ee8fabfd4b0e28ce807b8fddcd6f..32f111f44a71f6ff819d4dc5fa895a8168bfe9a7 100644
--- a/ansible/roles/elasticsearch_old/defaults/main.yml
+++ b/ansible/roles/elasticsearch_old/defaults/main.yml
@@ -7,7 +7,6 @@ es_logging_level: INFO
 es_etc_path_data: /var/lib/elasticsearch
 es_default_max_open_files: 65535
 es_etc_index_number_of_shards: 1
-es_default_es_heap_size: 512m
 es_version: "{{ es_release }}.{{es_minor_release}}"
 backup_storage_name:
 backup_storage_key:
diff --git a/ansible/roles/elasticsearch_old/tasks/debian.yml b/ansible/roles/elasticsearch_old/tasks/debian.yml
index 4e237570fb59d44c0000a146389c4a16421f9482..8a375e384868f8297dc9454516221d085cb73004 100644
--- a/ansible/roles/elasticsearch_old/tasks/debian.yml
+++ b/ansible/roles/elasticsearch_old/tasks/debian.yml
@@ -7,6 +7,12 @@
     repo: 'deb http://packages.elasticsearch.org/elasticsearch/2.x/debian stable main'
     state: present
 
+- name: Get information on the RAM
+  set_fact:
+    es_default_es_heap_size: "{% if ((ansible_memory_mb.real.total/(2*1024))|int) > 30000 %}26g{% else %}{{(((ansible_memory_mb.real.total/(2*1024))+1)|int)}}g{% endif %}"
+  when: es_default_es_heap_size is not defined
+
+
 - name: Copy /etc/default/elasticsearch
   template: src=elasticsearch dest=/etc/default/elasticsearch
   tags: update_es_config
diff --git a/ansible/roles/es6/tasks/elasticsearch-config.yml b/ansible/roles/es6/tasks/elasticsearch-config.yml
index 987de718dae57fbd70aa3fbec81ea04d5df0e59b..4f8ecc672d05be40ba2a44f854fa193cf7506f70 100644
--- a/ansible/roles/es6/tasks/elasticsearch-config.yml
+++ b/ansible/roles/es6/tasks/elasticsearch-config.yml
@@ -16,7 +16,6 @@
   with_items:
     - "{{data_dirs}}"
 
-
 #Copy the config template
 - name: Copy Configuration File
   become: yes
@@ -59,6 +58,11 @@
   template: src={{es_config_log4j2}} dest={{conf_dir}}/log4j2.properties owner={{ es_user }} group={{ es_group }} mode=0644 force=yes
   notify: restart elasticsearch
 
+- name: Get information on the RAM
+  set_fact:
+    es_heap_size: "{% if ((ansible_memory_mb.real.total/(2*1024))|int) > 26 %}26g{% else %}{{(((ansible_memory_mb.real.total/(2*1024))+1)|int)}}g{% endif %}"
+  when: es_heap_size is not defined
+
 - name: Copy jvm.options File for Instance
   become: yes
   template: src=jvm.options.j2 dest={{conf_dir}}/jvm.options owner={{ es_user }} group={{ es_group }} mode=0644 force=yes