# How to set node.roles for a coordinating only node via environment variable?

**URL:** <https://discuss.elastic.co/t/how-to-set-node-roles-for-a-coordinating-only-node-via-environment-variable/307860>\
**Category:** Elasticsearch\
**Tags:** docker\
**Created:** [June 22, 2022, 9:51am UTC](https://discuss.elastic.co/t/how-to-set-node-roles-for-a-coordinating-only-node-via-environment-variable/307860 "2022-06-22T09:51:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gerib](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gerib/32/106584_2.png) [@gerib](https://discuss.elastic.co/u/gerib)\
**Post date:** [June 22, 2022, 9:51am UTC](https://discuss.elastic.co/t/how-to-set-node-roles-for-a-coordinating-only-node-via-environment-variable/307860/1 "2022-06-22T09:51:29Z")

</div>

Same as in:

- (unanswered and closed) question here: [Problem with `node.roles` on latest Elasticsearch docker (7.11.0)](https://discuss.elastic.co/t/problem-with-node-roles-on-latest-elasticsearch-docker-7-11-0/264359)
- question (with an unsatisfying answer) on SO: [How to set default value while using env in elasticsearch.yml config file?](https://stackoverflow.com/q/67936479/1744774)

We, for instance, run ES via:

```auto
docker run ... -e node.roles=<What to define here for a coordinating only node?!?> ...

```

I tried various combinations like:

```auto
-e node.roles=
-e node.roles=''
-e node.roles=""

-e node.roles='""'
-e node.roles="''"
-e node.roles=[]
-e node.roles='[]'
-e node.roles="[]"
-e node.roles=[]
-e node.roles='[]'
-e node.roles="[]"
-e node.roles=()
-e node.roles='()'
-e node.roles="()"
-e node.roles=\'\'
... and more ...

```

... to no avail. (The first three work basically. They behave as if `node.roles` hasn't been mentioned at all and apply the default node settings.)

I even tried to find out how ES parses and interprets settings via environment at [GitHub - elastic/elasticsearch: Free and Open, Distributed, RESTful Search Engine](https://github.com/elastic/elasticsearch) but I didn't find the regarding piece of code yet.

---

<div class="post-metadata">

**Author:** ![pin007](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pin007/32/108560_2.png) [@pin007](https://discuss.elastic.co/u/pin007)\
**Post date:** [July 20, 2022, 9:30am UTC](https://discuss.elastic.co/t/how-to-set-node-roles-for-a-coordinating-only-node-via-environment-variable/307860/2 "2022-07-20T09:30:57Z")

</div>

I had similar problem and in the end I created my own docker image with customized entrypoint that updates elasticsearch.yml using `envsubst`

```auto
envsubst "${envvars}" < '/etc/elasticsearch/elasticsearch.template' > '/etc/elasticsearch/elasticsearch.yml'

```

`envvars` contains list of environment variables that I want to be processed, by default, without specifying individual variables, all variables are replaced. Also note, that if corresponding environment variable is missing it will be replaced by empty string.

---

<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:** [August 17, 2022, 9:31am UTC](https://discuss.elastic.co/t/how-to-set-node-roles-for-a-coordinating-only-node-via-environment-variable/307860/3 "2022-08-17T09:31:11Z")

</div>

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