How to Remove the Platform9 Host Agent

In certain scenarios the Platform9 Host Agent will need to be uninstalled and all CLI packages removed for a node to be successfully reused. This includes:

  • Cloning a VM that has Host Agent installed
  • Deauthorizing a node and re-running prep-node
  • Host Agent installation was interrupted causing the installation to fail
  • Node authorization fails due to network connectivity

To remove the Host Agent and the CLI follow the steps below.

Step 1

To completely reuse a node the node must be first detached from a cluster by using the Scale Workers or Scale Master command on the Infrastructure ‘Clusters’ dashboard or using the CLI. Once the node has been removed from the cluster it needs to be deauthorized form the Platform9 SaaS Management Plane. This can be done on the Infrastructure ‘Nodes’ dashboard by selecting the node and clicking the ‘Deauthorize Node’ table action. Once this command has been completed the node is detached and no longer under management.

The alternate approach is to delete the cluster and deauthorize all nodes.

Step 2

Ensure the Host Agent process is not running by running the command:

ps-ef |grep hostAgent

If the Host Agent is running stop the Host Agent process on the Node by running:

sudo kill -9 <<hostagent process PID>>

To get the PID run the command below:

ps -ef |grep hostagent
pf9       6643     1  0 04:04 ?        00:00:00 /bin/bash -c /opt/pf9/hostagent/bin/pf9-hostd >> /var/log/pf9/hostagent-daemon.log 2>&1
pf9       6645  6643  0 04:04 ?        00:07:52 /opt/pf9/hostagent/bin/python /opt/pf9/hostagent/bin/pf9-hostd
pf9admin 25496 28323  0 18:27 pts/1    00:00:00 grep --color=auto hostagent

Step 3

Remove the Host Agent by running

sudo apt-get purge pf9-hostagent

Example Host Agent Removal

sudo apt-get purge pf9-hostagent
[sudo] password for pf9admin:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  cgroup-tools ipvsadm keepalived libcgroup1 libnl-route-3-200 socat
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  pf9-comms* pf9-hostagent* pf9-muster*
0 upgraded, 0 newly installed, 3 to remove and 2 not upgraded.
After this operation, 211 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 154452 files and directories currently installed.)
Removing pf9-comms (4.5.0-770.6874f04) ...
Removing pf9-muster (4.5.0-343) ...
Removing pf9-hostagent (4.5.0-409.5192397) ...
Processing triggers for systemd (237-3ubuntu10.42) ...
Processing triggers for ureadahead (0.100.0-21) ...
(Reading database ... 141699 files and directories currently installed.)
Purging configuration files for pf9-comms (4.5.0-770.6874f04) ...
Purging configuration files for pf9-hostagent (4.5.0-409.5192397) ...
dpkg: warning: while removing pf9-hostagent, directory '/var/opt/pf9' not empty so not removed
dpkg: warning: while removing pf9-hostagent, directory '/var/log/pf9' not empty so not removed
dpkg: warning: while removing pf9-hostagent, directory '/opt/pf9/python/lib/python3.6/__pycache__' not empty so not removed
dpkg: warning: while removing pf9-hostagent, directory '/etc/pf9/certs' not empty so not removed

Once the Host Agent is removed you can proceed to removing the Platform9 CLI by following the commands below.

Uninstall of CLI

  • Remove directory /opt/pf9/cli
  • Remove directory ~/pf9
  • Remove the symlink /usr/bin/pf9ctl
sudo rm -fr /opt/pf9/cli
sudo rm -fr ~/pf9
sudo rm /usr/bin/pf9ctl

Clean up logs

Remove the existing logs

sudo rm -fr  /var/log/pf9