Upgrade from <6.0 ->6.4 fails with ES_PATH_CONF must be set to the configuration path chown: cannot access ‘/etc/elasticsearch/elasticsearch.keystore’: No such file or directory

Hello,

This problem has been raised multiple times but no resolution on any of the threads. I am hoping to get resolution on this one.

On CentOS 7, RPM update from a version < 6.0 -> 6.4 fails with this message and service doesn't come up.
ES_PATH_CONF must be set to the configuration path
chown: cannot access ‘/etc/elasticsearch/elasticsearch.keystore’: No such file or directory

Some research on ES_PATH_CONF and looking thru files found that, ES_PATH_CONF was introduced in 6.0. It was added to /etc/sysconfig/elasticsearch. RPM spec file defined this file as noreplace. So, upgrade from <6.0 ->6.4 created all the noreplace files are .rpmnew leaving the original file ( /etc/sysconfig/elasticsearch ) untouched. List of .rpmnew files
warning: /etc/elasticsearch/elasticsearch.yml created as /etc/elasticsearch/elasticsearch.yml.rpmnew
warning: /etc/elasticsearch/jvm.options created as /etc/elasticsearch/jvm.options.rpmnew
warning: /etc/elasticsearch/log4j2.properties created as /etc/elasticsearch/log4j2.properties.rpmnew
warning: /etc/init.d/elasticsearch created as /etc/init.d/elasticsearch.rpmnew
warning: /etc/sysconfig/elasticsearch created as /etc/sysconfig/elasticsearch.rpmnew
warning: /usr/lib/systemd/system/elasticsearch.service created as /usr/lib/systemd/system/elasticsearch.service.rpmnew

For 6.4, %posttrans section of RPM contains script to create /etc/elasticsearch/elasticsearch.keystore. This fails because it can't find ES_PATH_CONF. So, it prints the above message and quits.

Request to add migration for this script /etc/sysconfig/elasticsearch in %post section, something like this
grep -q -x -F 'ES_PATH_CONF' /etc/sysconfig/elasticsearch || echo 'ES_PATH_CONF=/etc/elasticsearch' >> /etc/sysconfig/elasticsearch

Without this change, any rpm updates from <6.0 to >=6.4 will fail with same error.

Appreciate if this can be addressed in any upcoming releases. Thanks !

Did you literally just change the repo source from 1.X to 6.X?

Moved to 6.1 a while ago. I am reporting a problem with 6.4 now.

1.x upgrade should be irrelevant for the problem mentioned. It would have happened with 5.6.14->6.4 as well.

Looks like there is an existing GitHub issue related to similar issue. Added comment there as well.