Elasticsearch as a service ignores ENVIRONMENT VARIABLES in /etc/environemnt

The documentation makes it sound as though you can set Environment Variables and use them in the /etc/elasticsearch/elasticsearch.yml file. It even gives ${HOSTNAME} as an example. According to Ubuntu, if I set a variable in /etc/environment, that variable name is available every time I log in.

When I set ES_HEAP_SIZE=4g or FOO=bar in my /etc/environment file I can see it with echo ${ES_HEAP_SIZE} or export -p but Elasticsearch completes ignores these variables.

I've seen some references to /etc/default/servicename via this post ([THIS POST]http://unix.stackexchange.com/questions/44370/how-to-make-unix-service-see-environment-variables)

AM I completely misreading the documentation? Does ES allow for reading/Importing of Environment Variables other than ${HOSTNAME} via the service?


If you run Elasticsearch from the command line do you still see the same behavior? Running Elasticsearch from the command line below shows it does pickup the environment variable and set the node name accordinglky.. How are you starting Elasticsearch? Upstart or systemd? I'd try using /etc/default/elasticsearch to set ES_HEAP_SIZE.

[msimos@msi-gs60 elasticsearch-2.3.1]$ hostname
[msimos@msi-gs60 elasticsearch-2.3.1]$ grep HOSTNAME config/elasticsearch.yml 
node.name: ${HOSTNAME}
[msimos@msi-gs60 elasticsearch-2.3.1]$ echo $HOSTNAME
[msimos@msi-gs60 elasticsearch-2.3.1]$ bin/elasticsearch
[2016-05-31 13:39:37,688][INFO ][node                     ] [msi-gs60] version[2.3.1], pid[26742], build[bd98092/2016-04-04T12:25:05Z]
[2016-05-31 13:39:37,688][INFO ][node                     ] [msi-gs60] initializing ...