mannoj
mannoj

Reputation: 465

Jinja template for salt

Elasticsearch HEAP calculation is IF MEM/2 > 31 SET ES_HEAP_SIZE=31 if not SET MEM/2.

{% set ES_HEAP_SIZE_RETURN={{ (0.51 * salt['grains.get']('mem_total'))|round|int }} %}

{% if ES_HEAP_SIZE_RETURN > 31744 %}
  {% set ES_HEAP_SIZE = '31744m' %}
    {% else %}
  {% set ES_HEAP_SIZE = [ ES_HEAP_SIZE_RETURN , "m" ] %}
{% endif %}

FINALLY it has to set ES_HEAP_SIZE in /etc/defaults/elasticsearch as per above calculation.

It doesn't work.

Upvotes: 1

Views: 154

Answers (1)

mannoj
mannoj

Reputation: 465

It worked, small changes to above one. Below one works charm.

{%- set ES_HEAP_SIZE_RETURN = (0.51 * salt['grains.get']('mem_total'))|round|int  %}

{% if ES_HEAP_SIZE_RETURN > 31744 %}  {% set ES_HEAP_SIZE = '31744m' %}   {% else %}  {% set ES_HEAP_SIZE = [ ES_HEAP_SIZE_RETURN , "m" ] %} {% endif %}

ES_HEAP_SIZE={{ES_HEAP_SIZE}}

Upvotes: 0

Related Questions