How to specify custom /etc/default file in elasticsearch 7

In the documentation it says explicitly

For the package distributions, the config directory location defaults to /etc/elasticsearch . The location of the config directory can also be changed via the ES_PATH_CONF environment variable, but note that setting this in your shell is not sufficient. Instead, this variable is sourced from /etc/default/elasticsearch (for the Debian package) and /etc/sysconfig/elasticsearch (for the RPM package). You will need to edit the ES_PATH_CONF=/etc/elasticsearch entry in one of these files accordingly to change the config directory location.

Is there a way to specify my own path for a different /etc/default/elasticsearch file for a package distribution installation? I already tried by adding the following in my systemd service file which uses the EnvironmentFile I want, but it still uses /etc/default/elasticsearch when the service is comming up.


The answer to this (at least for version 7.7.0) is that you can't do it seamlessly with any option or environment variable because it is not provided. However it is possible to edit the file /usr/share/elasticsearch/elasticsearch-env that comes with the package installation and replace line 81 with the following:

if [ ! -z "$ES_DEFAULT" ]; then
  source $ES_DEFAULT
  source /etc/default/elasticsearch

Then it is possible to set ES_DEFAULT in the system service file to point to a different /etc/default file.


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