================
Uninstalling AEN
================

Each AEN node must be uninstalled separately.

.. contents::
   :local:
   :depth: 1

Begin by setting the AEN Functional ID (NFI). The NFI is the username of the AEN
Service Account which is used to run all AEN services and is also the username
of the AEN Admin account. The NFI may be any name. The default NFI is
``wakari``. The NFI is also often set to ``aen_admin``. The NFI (and AEN
Functional Group or NFG) are described in
:doc:`the installation instructions <index>`.

Set the NFI with this command::

   export AEN_SRVC_ACCT="aen_admin"

Replace the name ``aen_admin`` with the NFI that was set in your installation of
Anaconda Enterprise Notebooks.

Uninstalling a server node
==========================

To remove a server node, run the following commands as root or sudo on the
server node's host system:

#. Stop the server processes:

   .. code-block:: bash

      service wakari-server stop

#. Stop MongoDB:

   .. code-block:: bash

      service mongod stop

#. Remove AEN server software, AEN database files and NGINX configuration:

   .. code-block:: bash

      rm -Rf /opt/wakari/wakari-server
      rm -Rf /opt/wakari/miniconda
      rm -Rf /var/lib/mongo/wakari*
      rm -Rf /etc/nginx/conf.d/www.enterprise.conf

   NOTE: Remove ``/etc/nginx/conf.d/www.enterprise.https.conf`` if SSL is
   enabled on the Server node.

#. Restart MongoDB and NGINX:

   .. code-block:: bash

      service mongod restart
      service nginx restart

#. Check for any outstanding server processes and stop them:

   .. code-block:: bash

      ps -ef | grep -e wakari-server -e wk-server

#. Remove the AEN Service Account:

   .. code-block:: bash

    userdel $AEN_SRVC_ACCT

#. Check for and remove any references to "aen" or "wakari" from
   the root user's ``.condarc`` file:

   .. code-block:: bash

      grep -i aen ~/.condarc
      grep -i wakari ~/.condarc


Uninstalling a gateway node
===========================

To uninstall a gateway node, run the following commands as root or sudo on the
gateway host system:

#. Stop the gateway processes:

   .. code-block:: bash

      service wakari-gateway stop

#. Remove gateway software:

   .. code-block:: bash

      rm -Rf /opt/wakari/wakari-gateway

#. Check for any outstanding gateway processes and stop them:

   .. code-block:: bash

      ps -ef | grep -e wakari-gateway -e wk-gateway

#. Remove the AEN Service Account:

   .. code-block:: bash

      userdel $AEN_SRVC_ACCT

#. Check for and remove any references to "aen" or "wakari" from the root user's ``.condarc`` file:

   .. code-block:: bash

      grep -i aen ~/.condarc
      grep -i wakari ~/.condarc

Uninstalling a compute node
===========================

To remove a compute node, run the following commands as root or
sudo on each compute node host system:

#. Stop the compute processes:

   .. code-block:: bash

      service wakari-compute stop

#. Remove the compute software:

   .. code-block:: bash

      rm -Rf /opt/wakari/wakari-compute
      rm -Rf /opt/wakari/miniconda
      rm -Rf /opt/wakari/anaconda

#. Check for any outstanding compute processes and stop them:

   .. code-block:: bash

      ps -ef | grep -e wakari-compute -e wk-compute

#. Remove the AEN Service Account:

   .. code-block:: bash

      userdel $AEN_SRVC_ACCT

#. Check for and remove any references to "aen" or "wakari" from the root user's ``.condarc`` file:

   .. code-block:: bash

      grep -i aen ~/.condarc
      grep -i wakari ~/.condarc


OPTIONAL: Removing projects from compute nodes
==============================================

CAUTION: This is an extreme measure and is not necessary in most
instances. We recommend you create and verify a backup before doing this
or any other file removal.

To remove all AEN projects from all of your compute nodes:

.. code-block:: bash

   rm -Rf /projects
