Installation - Cloud-Based Nodes
================================

Anaconda Adam can be used to create cloud-based instances and install Anaconda
platform components on the nodes.

Currently, Amazon EC2 is fully supported. To use Adam with other cloud
providers or instances that already exist on Amazon EC2, you can provision the
nodes following the :doc:`primary installation instructions <install>`.

Refer to the :doc:`requirements` page for more information about system
requirements, including networking and security requirements.

.. contents::
   :local:
   :depth: 2

1. Download Adam
----------------

Download the installer to the host machine where you want to manage the
cloud-based Anaconda platform:

.. code-block:: bash

    $ wget https://anaconda.org/anaconda-adam/adam-installer/4.2.3/download/adam-installer-4.2.3-Linux-x86_64.sh

or:

.. code-block:: bash

    $ curl -LO https://anaconda.org/anaconda-adam/adam-installer/4.2.3/download/adam-installer-4.2.3-Linux-x86_64.sh

2. Run the Installer
--------------------

Run the installer, and specify the destination directory (e.g., ``~/adam``):

.. code-block:: bash

    $ bash adam-installer-4.2.3-Linux-x86_64.sh -b -p ~/adam

Add the ``adam`` command to your path by modifying ``~/.bashrc``:

.. code-block:: bash

    $ echo -e '\n# Anaconda Adam\nexport PATH=~/adam/bin:$PATH' >> ~/.bashrc

Source your ``~/.bashrc`` file to activate the changes:

.. code-block:: bash

    $ source ~/.bashrc

Run the ``adam`` command to verify the installation and to create the configuration directories:

.. code-block:: bash

    $ adam

3. License File (Optional)
--------------------------

If you have an Anaconda Workgroup, Anaconda Enterprise, or other Anaconda
license file, you can copy it to the ``~/adam/licenses`` directory. Anaconda
Adam will search this directory for license files named ``license*.txt``, e.g.,
``~/adam/licenses/license_bundle_20160524191753.txt``.

TIP: In addition to ``~/adam/licenses/``, Adam checks for license files in
``~/.continuum/`` and the other directories shown by the command
``~/adam/bin/conda info --license``, so you may place the license file in any of
these directories.

4. Configure AWS credentials
----------------------------

Configure your AWS credentials including your AWS Access Key ID, AWS Secret
Access Key, and (optionally) your default region in a file named
``~/.aws/credentials``. An example credentials file is shown below:

.. code-block:: none

    [default]
    aws_access_key_id = YOUR_ACCESS_KEY
    aws_secret_access_key = YOUR_SECRET_KEY
    region = us-east-1

Refer to the
`boto documentation <https://boto3.readthedocs.io/en/latest/guide/quickstart.html#configuration>`_
for more information on configuring your AWS credentials.

5. Create Cluster
-----------------

Create your cluster on Amazon EC2 using:

.. code-block:: bash

    $ adam ec2 -n my-cluster up

The keyname and keypair are required arguments. You can optionally specify the
AMI, number of nodes, instance types, etc.

.. code-block:: bash

    $ adam ec2 -n my-cluster up --help
    Usage: adam ec2 up [OPTIONS]

    Options:
      --keyname TEXT                Keyname on EC2 console  [required]
      --keypair PATH                Path to the keypair that matches the keyname
                                    [required]
      --vpc-id TEXT                 EC2 VPC ID
      --subnet-id TEXT              EC2 Subnet ID on the VPC
      --region-name TEXT            AWS region  [default: us-east-1]
      --ami TEXT                    EC2 AMI  [default: ami-d05e75b8]
      --username TEXT               User to SSH to the AMI  [default: ubuntu]
      --type TEXT                   EC2 Instance Type  [default: m4.xlarge]
      --count INTEGER               Number of nodes  [default: 4]
      --security-group TEXT         Security Group Name  [default: adam-default]
      --volume-type TEXT            Root volume type  [default: gp2]
      --volume-size INTEGER         Root volume size (GB)  [default: 500]
      -t, --tag TEXT                Extra tags to add to the instances
      --check-ami / --no-check-ami  Whether or not to check the AMI  [default:
                                    True]
      --provision / --no-provision  Provision salt on the nodes  [default: True]
      -y, --yes                     Answers yes to questions
      -h, --help                    Show this message and exit.

6. Install Platform Components
------------------------------

After creating a cluster, you can install platform components using
``adam <platform-component> install``:

.. code-block:: bash

    $ adam repository -n my-cluster install
    $ adam enterprise-notebooks -n my-cluster install
    $ adam mosaic -n my-cluster install
    $ adam accelerate -n my-cluster install
    $ adam scale -n my-cluster cluster install
    $ adam scale -n my-cluster dask install

7. Access Platform Components
-----------------------------

After the platform component installations complete, you can open the platform
component interfaces in your browser using ``adam <platform-component> open``:

.. code-block:: bash

    $ adam repository -n my-cluster open
    $ adam enterprise-notebooks -n my-cluster open
    $ adam mosaic -n my-cluster open

Refer to the :doc:`getting-started` page for more information about using
the Anaconda platform components.

8. Destroy Cluster
------------------

To destroy the cluster and instances:

.. code-block:: bash

    $ adam ec2 -n my-cluster destroy
