# Help me set elasticsearch.yml variable

**URL:** <https://discuss.elastic.co/t/help-me-set-elasticsearch-yml-variable/224228>\
**Category:** Elasticsearch\
**Created:** [March 19, 2020, 8:24am UTC](https://discuss.elastic.co/t/help-me-set-elasticsearch-yml-variable/224228 "2020-03-19T08:24:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jw.lee](https://avatars.discourse-cdn.com/v4/letter/j/9dc877/32.png) [@jw.lee](https://discuss.elastic.co/u/jw.lee)\
**Post date:** [March 19, 2020, 8:24am UTC](https://discuss.elastic.co/t/help-me-set-elasticsearch-yml-variable/224228/1 "2020-03-19T08:24:45Z")

</div>

This is the contents of my elasticsearch.yml file.

* * *

```
cluster.name: test-cluster
node.name: test-m
node.master: true
node.data: false

cluster.initial_master_nodes: ["${ES_MASTER_NODES}"]
discovery.seed_hosts: ["${ES_SEED_HOSTS}"]

network.host: 0.0.0.0
network.publish_host: ${ES_PUBLISH_HOST}

```

* * *

'discovery.seed\_hosts' don't recognize it properly

'discovery.seed\_hosts : ['192.xxx.xxx.11 ','192.xxx.xxx.12 ','192.xxx.xxx.13 ']  
Works fine.  
However, I want to create a variable called '$ {ES\_SEED\_HOSTS}' and use it to run it.

${ES\_SEED\_HOSTS} = "'192.xxx.xxx.11','192.xxx.xxx.12','192.xxx.xxx.13'"

[2020-03-19T08:04:10,831][WARN][o.e.d.SeedHostsResolver] [test-m] failed to resolve host ['192.xxx.xxx.11']`Preformatted text`  
java.net.UnknownHostException: '192.xxx.xxx.11'  
[2020-03-19T08:04:10,831][WARN][o.e.d.SeedHostsResolver] [test-m] failed to resolve host ['192.xxx.xxx.12']  
java.net.UnknownHostException: '192.xxx.xxx.12'  
[2020-03-19T08:04:10,831][WARN][o.e.d.SeedHostsResolver] [test-m] failed to resolve host ['192.xxx.xxx.13']  
java.net.UnknownHostException: '192.xxx.xxx.13'

How should we put the value of the variable?  
{ES\_SEED\_HOSTS} / ~ export ES\_SEED\_HOSTS=" ?? "

---

<div class="post-metadata">

**Author:** ![Bernt\_Rostad](https://avatars.discourse-cdn.com/v4/letter/b/3ab097/32.png) [@Bernt\_Rostad](https://discuss.elastic.co/u/Bernt_Rostad)\
**Post date:** [March 19, 2020, 12:59pm UTC](https://discuss.elastic.co/t/help-me-set-elasticsearch-yml-variable/224228/2 "2020-03-19T12:59:56Z")

</div>

> [@jw.lee](#):
>
> How should we put the value of the variable?

I'm using an older (6.8) version of Elasticsearch so I call my environment variable ES\_DISOVERY\_HOSTS which I export with a setting like this:

`export ES_DISCOVERY_HOSTS="master1:9260","master2:9260","master3:9260"`

where I include the port numbers because I run several master eligible instances on the same physical servers (listening to different ports for different clusters).

Then all I need to do in **elasticsearch.yml** on each data node is add

`discovery.zen.ping.unicast.hosts: ${ES_DISCOVERY_HOSTS}`

In your case this would be **discovery.seed\_hosts**.

Good luck!

---

<div class="post-metadata">

**Author:** ![jw.lee](https://avatars.discourse-cdn.com/v4/letter/j/9dc877/32.png) [@jw.lee](https://discuss.elastic.co/u/jw.lee)\
**Post date:** [March 20, 2020, 1:19am UTC](https://discuss.elastic.co/t/help-me-set-elasticsearch-yml-variable/224228/3 "2020-03-20T01:19:30Z")

</div>

The version I installed is 7.4.2  
If you enter it directly without using an environment variable, the execution will work fine.  
What I want is to put an environment variable in discovery.seed\_hosts but is that impossible?

---

<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:** [April 17, 2020, 1:19am UTC](https://discuss.elastic.co/t/help-me-set-elasticsearch-yml-variable/224228/4 "2020-04-17T01:19:32Z")

</div>

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