Skip to content

[Elastic Agent] Install/uninstall subcommand #21019

@blakerouse

Description

@blakerouse

Overview

With the new self-upgrading Elastic Agent work, installation/uninstallation of Elastic Agent needs to be adjusted. This issue documents the work to be done to add 2 new sub-commands install and uninstall.

DEB/RPM Packaging & Docker

DEB/RPM packaging and Docker images will not support auto-upgrading. The fact that they cannot be upgraded will be reported to Fleet. Standard DEB/RPM and Docker image upgrade process must be used when that method of consumption is used.

Using the install sub-command on Linux will allow Elastic Agent to be auto-upgraded. Linux will be the only OS that supports both auto-upgrade and standard version installation.

Install Command

This command will perform the proper installation of Elastic Agent on the OS. Depending on the OS the installation path of Elastic Agent will change, but the internal structure of the Elastic Agent's directories remain the same.

The install command will be interactive asking the correct questions so Elastic Agent operates the way the user expects once installed. The interactive part can be skipped by using -f in which case the default options will always be taken and no questions will be asked.

Fresh Installation Interactive

Below documents the flow of installation Elastic Agent and the interactive questions that will be asked.

$ ./elastic-agent install
Elastic Agent will be installed onto your system and will run as a service, do you want to continue [Y/n]: y
Success: Installation of the Elastic Agent was successful and it is currently running.

Do you want to Enroll this Elastic Agent into a Fleet [y/N]: Y
URL of Kibana: http://localhost:5601
Enrollment Token for Fleet: theusersgeneratedenrollmenttoken
Success: Enrollment of the Elastic Agent was successful.

Fresh Installation Non-Interactive

Below documents the installation of Elastic Agent non-interactive.

$ ./elastic-agent install -f --kibana-url http://localhost:5601 --enrollment-token theusersgeneratedenrollmenttoken
Success: Installation of the Elastic Agent was successful and it is currently running.

Installation Upgrade

Below documents the flow of running the installation of Elastic Agent, but there is already an older version of Elastic Agent installed.

$ ./elastic-agent install
Elastic Agent is already installed onto your system, do you want to upgrade it to this version [Y/n]: y
Success: Upgrade of the Elastic Agent was successful and it is currently running.

Installation Locations

Below documents the installation locations based on the type of OS. These paths will be hard-coded and will not be possible to be adjusted for installation. The running Elastic Agent will check that its running from the defined directories to enable self-upgrading.

  • Linux:

    • /opt/Elastic/Agent/* - Elastic Agent program files
    • /opt/Elastic/Agent/elastic-agent.yml - Main Elastic Agent configuration
    • /opt/Elastic/Agent/fleet.yml - Main Elastic Agent Fleet configuration
    • /opt/Elastic/Agent/elastic-agent.sock - Running Elastic Agent communication socket
    • /opt/Elastic/Agent/elastic-agent.log - Log files for Elastic Agent
    • /usr/bin/elastic-agent - Shell wrapper installed into PATH
  • Mac:

    • /Library/Elastic/Agent/* - Elastic Agent program files
    • /Library/Elastic/Agent/elastic-agent.yml - Main Elastic Agent configuration
    • /Library/Elastic/Agent/fleet.yml - Main Elastic Agent Fleet configuration
    • /Library/Elastic/Agent/elastic-agent.sock - Running Elastic Agent communication socket
    • /Library/Elastic/Agent/elastic-agent.log - Log files for Elastic Agent
    • /usr/bin/elastic-agent - Shell wrapper installed into PATH
  • Windows:

    • C:\Program/ Files\Elastic\Agent* - Elastic Agent program files
    • C:\Program/ Files\Elastic\Agent\elastic-agent.yml - Main Elastic Agent configuration
    • C:\Program/ Files\Elastic\Agent\fleet.yml - Main Elastic Agent Fleet configuration
    • C:\Program/ Files\Elastic\Agent\elastic-agent.sock - Running Elastic Agent communication socket
    • C:\Program/ Files\Elastic\Agent\elastic-agent.log - Log files for Elastic Agent

Self-upgrading

Self-upgrading will only be enabled when Elastic Agent is installed. Starting Elastic Agent from an extracted .tar.gz(.zip) without it being installed, will mark the Elastic Agent as not being able to be self-upgraded. This information will be reported to Fleet to inform Fleet that it cannot be upgraded.

Uninstall Command

The command can only be ran by an installed Elastic Agent. Running it from an Elastic Agent will report a message informing the user to run it against the installed Elastic Agent, if one is installed.

This command will inform the current running Elastic Agent that it's going to be uninstalled, so the Elastic Agent can un-installed Elastic Endpoint Security if its installed/running and stop the running Beats. Once the running Elastic Agent has exited and stopped, then the installation files will be removed.

This command is also interactive, unless the -f is used.

Uninstall Interactive

$ elastic-agent uninstall
Elastic Agent will be uninstalled from your system, do you want to continue, this cannot be un-done [Y/n]: y
Success: Elastic Agent has been successfully uninstalled.

Uninstall Non-interactive

$ elastic-agent uninstall -f
Success: Elastic Agent has been successfully uninstalled.

Uninstall from extracted archive

$ ./elastic-agent uninstall
Uninstall must be called from an installed Elastic Agent. Try running `elastic-agent uninstall` instead.
$ echo $?
1

Metadata

Metadata

Assignees

Labels

needs_teamIndicates that the issue/PR needs a Team:* label

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions