Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

[Fleet / Agent ] support install / uninstall command from Agent #326

Closed
EricDavisX opened this issue Sep 24, 2020 · 3 comments · Fixed by #378
Closed

[Fleet / Agent ] support install / uninstall command from Agent #326

EricDavisX opened this issue Sep 24, 2020 · 3 comments · Fixed by #378
Assignees
Labels
Team:Elastic-Agent Label for the Agent team

Comments

@EricDavisX
Copy link
Contributor

I'm going to put some thoughts down for this.

From this issue: elastic/beats#21019

  • its merging in the next day or two so would be good to prep some feature file work and implementation as needed.

briefly:
the feature adds in new support, and leaves the old in place.
So we'll still want to test the enroll and unenroll as we are. but we can add in new feature tests for 'install' and 'uninstall' from the Agent side.

@EricDavisX EricDavisX added the Team:Elastic-Agent Label for the Agent team label Sep 24, 2020
@EricDavisX
Copy link
Contributor Author

EricDavisX commented Sep 24, 2020

here are the tests I propose we add, to a new file agent_subcommands.feature:
As I see it, most of this is re-used code, but there will be 3 new steps:
Given a "os" agent is deployed to Fleet with install command
When the agent is "restarted" on the host
... values I want to support here initially are "uninstalled", "restarted"
And the file system Agent folder is empty

The other subcommands that are already tested are:
enroll Enroll the Agent into Fleet
run Start the elastic-agent.

The newly tested subcommands added here are:
install Install Elastic Agent permanently on this system
restart Restart the currently running Elastic Agent daemon
uninstall Uninstall permanent Elastic Agent from this system

The as yet tested subcommands are:
help Help about any command
inspect Shows configuration of the agent
version Shows the version

This only has one test for the new 'uninstall' command, and it uninstalls an active running installation.
We could expand this to more coverage for error / recovery cases and how the subcommands support usage.

#Tests

@install
Scenario Outline: Deploying the agent with install command
Given a "os" agent is deployed to Fleet with install command
Then the agent is listed in Fleet as "online"
And the "filebeat" process is in the "started" state on the host
And the "metricbeat" process is in the "started" state on the host
And system package dashboards are listed in Fleet
Examples:
| os |
| centos |
| debian |

@stop-installed-agent
Scenario Outline: Stopping an 'installed' agent stops backend processes
Given a "os" agent is deployed to Fleet with install command
When the "elastic-agent" process is "stopped" on the host
Then the "filebeat" process is in the "stopped" state on the host
And the "metricbeat" process is in the "stopped" state on the host
Examples:
| os |
| centos |
| debian |

@restart-installed-host
Scenario Outline: Restarting the installed host restarts backend processes
Given a "os" agent is deployed to Fleet with install command
When the host is restarted
Then the "elastic-agent" process is in the "started" state on the host
And the "filebeat" process is in the "started" state on the host
And the "metricbeat" process is in the "started" state on the host
Examples:
| os |
| centos |
| debian |

@unenroll-installed-host
Scenario Outline: Un-enrolling the installed agent
Given a "os" agent is deployed to Fleet with install command
When the agent is un-enrolled
Then the "elastic-agent" process is in the "started" state on the host
And the agent is listed in Fleet as "inactive"
And the "filebeat" process is in the "stopped" state on the host
And the "metricbeat" process is in the "stopped" state on the host
Examples:
| os |
| centos |
| debian |

@reenroll-installed-host
Scenario Outline: Re-enrolling the installed agent
Given a "os" agent is deployed to Fleet with install command
And the agent is un-enrolled
And the "elastic-agent" process is "stopped" on the host
When the agent is re-enrolled on the host
And the "elastic-agent" process is "started" on the host
Then the agent is listed in Fleet as "online"
Examples:
| os |
| centos |
| debian |

@uninstall-installed-host
Scenario Outline: Un-installing the installed agent
Given a "os" agent is deployed to Fleet with install command
When the agent is "uninstalled" on the host
Then the "elastic-agent" process is in the "stopped" state on the host
And the agent is listed in Fleet as "inactive"
And the "filebeat" process is in the "stopped" state on the host
And the "metricbeat" process is in the "stopped" state on the host
And the file system Agent folder is empty
(Agent may end up deleted, if so we change this to 'Elastic folder does not have an Agent subfolder'

@restart-installed-host
Scenario Outline: Restarting the installed agent
Given a "os" agent is deployed to Fleet with install command
When the agent is "restarted" on the host
And the agent is listed in Fleet as "online"
And the "filebeat" process is in the "started" state on the host
And the "metricbeat" process is in the "started" state on the host

@EricDavisX
Copy link
Contributor Author

Further to note, there is an install -f and an uninstall -f that we will use here. Without the -f we'd need to interactively try to pass info to the command line for Agent to process. @mdelapenya do you think that would be possible? it would be great to have both covered, but just the -f is enough to start.

Also, the install command is really quite similar to the enroll, it takes basically the same arguments, here are the 2 to compare:

elastic-agent enroll https://8040186313ec4a228ecc22ebee9ed123.us-central1.gcp.foundit.no:443 YW9mUm9YUUJWMUZuVTV1TlJNeTQ6WjBTQ3R6VFZUb0toeTBEQ05CcGV123==

elastic-agent install -f --kibana-url https://8040186313ec4a228ecc22ebee9e123.us-central1.gcp.foundit.no:9243 --enrollment-token YW9mUm9YUUJWMUZuVTV1TlJNeTQ6WjBTQ3R6VFZUb0toeTBEQ05CcGV123==

@mdelapenya
Copy link
Contributor

As commented yesterday in Slack, we are going to create an installer for TAR, which will be the only one using the install/uninstall subcommands. We are able to apply this installation mechanism to both Centos and Debian, although it could be expanded to cover other Linux distros having an official Docker image.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Team:Elastic-Agent Label for the Agent team
Projects
None yet
3 participants