elastic / elastic-agent

Elastic Agent - single, unified way to add monitoring for logs, metrics, and other types of data to a host.
Other
127 stars 136 forks source link

Support RPM install better with custom --prefix option. #141

Open ajoliveira opened 2 years ago

ajoliveira commented 2 years ago

Describe the enhancement: For comparison, the Elasticsearch RPM file allows relocation of the /usr directory ONLY.

RPM supports the use of a '--prefix' flag (ex: --prefix=/opt) to change the installation path of files listed in the matching directory (if allowed). For example, the following rpm command output - ex: Relocations:

[elastic@localhost ~]$ rpm -qip metricbeat-7.15.1-x86_64.rpm
Name        : metricbeat
Version     : 7.15.1
Release     : 1
Architecture: x86_64
Install Date: (not installed)
Group       : default
Size        : 175184387
License     : Elastic-License
Signature   : RSA/SHA512, Thu 07 Oct 2021 08:35:04 PM EDT, Key ID d27d666cd88e42b4
Source RPM  : metricbeat-7.15.1-1.src.rpm
Build Date  : Thu 07 Oct 2021 06:26:04 PM EDT
Build Host  : 030a0d86dfd1
Relocations : /
Packager    : <@030a0d86dfd1>
Vendor      : Elastic
URL         : https://www.elastic.co/beats/metricbeat
Summary     : Metricbeat is a lightweight shipper for metrics.
Description :
Metricbeat is a lightweight shipper for metrics.

In the case of metricbeat, the 3 top level directories that are used for install are /etc, /lib, and /usr. Since the allowed relocation is the top-level root directory /, all 3 directories will be moved since they are sub-directories of this directory. This has an unfortunate side effect that if you are not able to install into /usr for example, you cannot change ONLY that directory. Installing with the --prefix=/opt/metricbeat option: sudo rpm -ivh --prefix=/opt/metricbeat metricbeat-7.15.1-x86_64.rpm

everything ends up in /opt/metricbeat with no files/directories in /etc/ or /lib and no service is installed. The workaround can be used to add the service and update configuration files, ex: 1) move files from /opt/metricbeat/etc/* to /etc and /opt/metricbeat/lib/* to /lib

Describe a specific use case for the enhancement or feature: In some cases, users are not allowed to (or it is recommended that they not) install any files to the /usr directory and would prefer to install to the /opt directory as an alternative - WHILE still allowing for proper installation relative to configuration files and startup scripts/services and not require manual steps to get working properly.

ajoliveira commented 2 years ago

Checked Elastic-Agent and it also has same 'Relocations' directory and I assume would have same issue - failing to install service, etc. Adding/changing labels accordingly.

elasticmachine commented 2 years ago

Pinging @elastic/elastic-agent (Team:Elastic-Agent)

elasticmachine commented 2 years ago

Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane)

jlind23 commented 2 years ago

@nimarezainia could you please have a look.

nimarezainia commented 2 years ago

@ajoliveira sorry for the delay. Was there a specific customer request for this? I understand the use case and why it could be important.

I would prefer to make this enhancement to elastic-agent. your thoughts?

nimarezainia commented 2 years ago

@ajoliveira pls let me know. At the moment ideally I'd like to concentrate on customer found enhancement requests

ajoliveira commented 2 years ago

@nimarezainia Yes, this was found as an issue at a customer installation. Details were provided in direct a e-mail and while it was originally specific to metricbeat, I'll defer to you as to when and how we can implement this. While not optimal, there is a workaround if needed in the meantime.

pierrehilbert commented 10 months ago

@nimarezainia should we spend some time on this one or is it something we want to only allow when installed from tar.gz?

nimarezainia commented 10 months ago

@pierrehilbert can the rpm/deb at all use a different install location?

pierrehilbert commented 10 months ago

Not currently, only possible when installing through CLI.