# How to configure ES\_JAVA\_OPTS for ES 5.0 using ansible playbook

**URL:** <https://discuss.elastic.co/t/how-to-configure-es-java-opts-for-es-5-0-using-ansible-playbook/65490>\
**Category:** Elasticsearch\
**Created:** [November 9, 2016, 1:15pm UTC](https://discuss.elastic.co/t/how-to-configure-es-java-opts-for-es-5-0-using-ansible-playbook/65490 "2016-11-09T13:15:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![r.ganeshbabu](https://avatars.discourse-cdn.com/v4/letter/r/4da419/32.png) [@r.ganeshbabu](https://discuss.elastic.co/u/r.ganeshbabu)\
**Post date:** [November 9, 2016, 1:15pm UTC](https://discuss.elastic.co/t/how-to-configure-es-java-opts-for-es-5-0-using-ansible-playbook/65490/1 "2016-11-09T13:15:28Z")

</div>

Hi All,

I am trying to start Elasticsearch 5.0.0 using ansible playbook and I am getting the below error I tried to by giving **ES\_JAVA\_OPTS="-Xms1g -Xmx1g"** in elasticsearch.j2 (template) but still unable to resolve the below error

> fatal: [10.247.0.31]: FAILED! =\> {"changed": true, "cmd": ["sudo", "service", "master\_node\_elasticsearch", "start"], "delta": "0:00:00.086526", "end": "2016-11-09 07:46:34.015391", "failed": true, "rc": 1, "start": "2016-11-09 07:46:33.928865", "stderr": "", "stdout": "Starting elasticsearch: Error: encountered environment variables that are no longer supported\nUse jvm.options or ES\_JAVA\_OPTS to configure the JVM\nES\_HEAP\_SIZE=1g: set -Xms1g and -Xmx1g in jvm.options or add "-Xms1g -Xmx1g" to ES\_JAVA\_OPTS\n[FAILED]", "stdout\_lines": ["Starting elasticsearch: Error: encountered environment variables that are no longer supported", "Use jvm.options or ES\_JAVA\_OPTS to configure the JVM", "ES\_HEAP\_SIZE=1g: set -Xms1g and -Xmx1g in jvm.options or add "-Xms1g -Xmx1g" to ES\_JAVA\_OPTS", "[FAILED]"], "warnings": ["Consider using 'become', 'become\_method', and 'become\_user' rather than running sudo"]}

Please help us to setup the JVM for ES 5.0.0

Thanks,  
Ganeshbabu R

---

<div class="post-metadata">

**Author:** ![ywelsch](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ywelsch/32/7751_2.png) [@ywelsch](https://discuss.elastic.co/u/ywelsch)\
**Post date:** [November 9, 2016, 1:30pm UTC](https://discuss.elastic.co/t/how-to-configure-es-java-opts-for-es-5-0-using-ansible-playbook/65490/2 "2016-11-09T13:30:12Z")

</div>

Which playbook are you using? The one provided [here](https://github.com/elastic/ansible-elasticsearch) is not 5.x compatible yet but there is [active work](https://github.com/elastic/ansible-elasticsearch/pull/182) on it.

---

<div class="post-metadata">

**Author:** ![r.ganeshbabu](https://avatars.discourse-cdn.com/v4/letter/r/4da419/32.png) [@r.ganeshbabu](https://discuss.elastic.co/u/r.ganeshbabu)\
**Post date:** [November 9, 2016, 1:42pm UTC](https://discuss.elastic.co/t/how-to-configure-es-java-opts-for-es-5-0-using-ansible-playbook/65490/3 "2016-11-09T13:42:09Z")

</div>

Thanks @ywelsch for showing the active work.👍

I will try to setup ES 5.0

---

<div class="post-metadata">

**Author:** ![r.ganeshbabu](https://avatars.discourse-cdn.com/v4/letter/r/4da419/32.png) [@r.ganeshbabu](https://discuss.elastic.co/u/r.ganeshbabu)\
**Post date:** [November 14, 2016, 10:51am UTC](https://discuss.elastic.co/t/how-to-configure-es-java-opts-for-es-5-0-using-ansible-playbook/65490/4 "2016-11-14T10:51:43Z")

</div>

Hi @ywelsch

I had a little doubt in setting up ES 5.0 and I am following [ES 5.x support active work](https://github.com/elastic/ansible-elasticsearch/pull/182) but getting below error,

> fatal: [10.247.0.5]: FAILED! =\> {"changed": true, "cmd": ["sudo", "service", "master\_node\_elasticsearch", "start"], "delta": "0:00:00.054053", "end": "2016-11-14 05:09:33.621534", "failed": true, "rc": 7, "start": "2016-11-14 05:09:33.567481", "stderr": "", "stdout": "MAX\_LOCKED\_MEMORY is set - ES\_HEAP\_SIZE must also be set", "stdout\_lines": ["MAX\_LOCKED\_MEMORY is set - ES\_HEAP\_SIZE must also be set"], "warnings": ["Consider using 'become', 'become\_method', and 'become\_user' rather than running sudo"]}

Though I have given the es\_heap\_size value in my playbook but still getting the error.

I have attached the my playbook for your reference and somewhere I am doing mistake & pls correct me

> * * *
> 
> - name: Elasticsearch with custom configuration  
> strategy: debug  
> #hosts: localhost  
> hosts: 10.247.0.5  
> remote\_user: esadmin  
> sudo: yes  
> roles:
> - { role: elasticsearch, es\_instance\_name: "master\_node",  
> es\_config: {  
> node.name: "master\_node",  
> cluster.name: "ES\_LOCAL\_CLUSTER",  
> discovery.zen.ping.unicast.hosts: "10.247.0.5:9301",  
> http.port: 9201,  
> transport.tcp.port: 9301,  
> node.data: true,  
> node.master: true,  
> bootstrap.memory\_lock: true,  
> #bootstrap.mlockall: true,  
> discovery.zen.ping.multicast.enabled: false,  
> network.host: "10.247.0.5"  
> }  
> }  
> vars:  
> es\_remote\_user: esadmin  
> es\_scripts: true  
> es\_templates: false  
> es\_version\_lock: false  
> es\_heap\_size: 1g  
> es\_java\_opts: "-Xms1g -Xmx1g"

Regards,  
Ganeshbabu R

---

<div class="post-metadata">

**Author:** ![carrot](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carrot/32/44335_2.png) [@carrot](https://discuss.elastic.co/u/carrot)\
**Post date:** [November 15, 2016, 2:33am UTC](https://discuss.elastic.co/t/how-to-configure-es-java-opts-for-es-5-0-using-ansible-playbook/65490/5 "2016-11-15T02:33:27Z")

</div>

You don't need to use es\_java\_opts. But you should probably make sure that jvm.options goes in /etc/elasticsearch/jvm.options. Doesn't seem like this file is working in default.path.conf. I believe there is an open issue about this. Playbook needs modified to support that (It does delete the default jvm.options).

Also make sure there is nothing in /usr/share/elasticsearch/plugins/

Remove this

```
# TODO: Re-enable when fixed in ES 5.0.1
#- name: Delete Default JVM Options File (5.x)
# file: dest=/etc/elasticsearch/jvm.options state=absent

```

And change to this

```
# TODO: Disable when fixed in ES 5.0.1
- name: Copy jvm.options File for Instance
  template: src=jvm.options.j2 dest=/etc/elasticsearch/jvm.options owner={{ es_user }} group={{ es_group }} mode=0644 force=yes
  notify: restart elasticsearch
  when: es_version | version_compare('5.0', '>=')

```

Hopefully that helps your situation. That's how I could run 3 process on the same server.

---

<div class="post-metadata">

**Author:** ![r.ganeshbabu](https://avatars.discourse-cdn.com/v4/letter/r/4da419/32.png) [@r.ganeshbabu](https://discuss.elastic.co/u/r.ganeshbabu)\
**Post date:** [November 17, 2016, 6:41am UTC](https://discuss.elastic.co/t/how-to-configure-es-java-opts-for-es-5-0-using-ansible-playbook/65490/6 "2016-11-17T06:41:01Z")

</div>

Hey @carrot

I have tried the same setting as you suggested and I could see its trying to start ES from the path  
**/usr/share/elasticsearch/bin/elasticsearch**

but It fails to start ES and I got the following error,

> fatal: [10.247.0.5]: FAILED! =\> {"changed": true, "cmd": ["service", "master\_node\_elasticsearch", "start"], "delta": "0:00:00.050567", "end": "2016-11-17 01:26:21.900953", "failed": true, "rc": 7, "start": "2016-11-17 01:26:21.850386", "stderr": "", "stdout": **"/usr/share/elasticsearch/bin/elasticsearch** \nMAX\_LOCKED\_MEMORY is set - ES\_HEAP\_SIZE must also be set", "stdout\_lines": **["/usr/share/elasticsearch/bin/elasticsearch",**"MAX\_LOCKED\_MEMORY is set - ES\_HEAP\_SIZE must also be set"], "warnings": ["Consider using service module rather than running service"]}

when I check jvm\_options file path it placed in **/etc/elasticsearch** and heap size value also append to the min & max

 ![](https://us1.discourse-cdn.com/elastic/original/2X/a/a25c07f5e2f156d17c3710de64ce3f6b79681b50.png)

Please let me know your thoughts..

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 15, 2016, 6:41am UTC](https://discuss.elastic.co/t/how-to-configure-es-java-opts-for-es-5-0-using-ansible-playbook/65490/7 "2016-12-15T06:41:00Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
