===================================
Installing into a cloud environment
===================================

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

Currently, Adam fully supports Amazon Elastic Compute Cloud
(EC2).

To use Adam with instances that already exist on Amazon EC2, or
with other cloud providers, follow the
:doc:`primary installation instructions <standard>`.

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

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


Downloading the Adam installer
==============================

To download the installer, run one of the commands below on the
host machine where you want to manage the Anaconda platform:

.. code-block:: bash

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

Or:

.. code-block:: bash

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


Installing Adam
===============

#. Run the installer, specifying the installation directory:

   .. code-block:: bash

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

   NOTE: Replace ``~/adam`` with the actual installation
   directory.

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

   .. code-block:: bash

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

#. To activate the changes, source your ``~/.bashrc`` file:

   .. code-block:: bash

      source ~/.bashrc


Verifying the installation
==========================

To verify that the installation succeeded and to create
configuration files in ``~/.continuum/adam``,
run the ``adam`` command, which outputs the Adam help text:

.. code-block:: bash

    $ adam
    Usage: adam [OPTIONS] COMMAND [ARGS]...

    Options:
      --version                    Show the version and exit.
      -l, --log-level [info|debug|error]
                                   Logging level [default: debug]
      -h, --help                   Show this message and exit.

    Commands:
      cmd                   Execute a command on the nodes
      describe              Describe an Adam cluster or profile
      ec2                   EC2 options
      enterprise-notebooks  Anaconda Enterprise Notebooks options
      info                  Display Adam version, system, and
                              license information
      jupyter               Jupyter options
      kubernetes            Kubernetes options
      list                  List Adam clusters and profiles
      platform              Anaconda Platform options
      provision             Provision options
      remove                Remove a cluster
      repository            Anaconda Repository options
      salt                  Execute a Salt module
      scale                 Anaconda Scale options
      ssh                   SSH to one of the nodes (0-based
                              index)
      up                    Create a cluster from a profile


Installing your Anaconda Enterprise license file
================================================

Copy your Anaconda Enterprise license file to any of the
following directories:

* ``~/adam/licenses/``.
* ``~/.continuum/``.
* Any other directory shown by the command
  ``~/adam/bin/conda info --license``.

Adam searches all of these directories for license files named ``license*.txt``.

EXAMPLE: ``~/adam/licenses/license_bundle_20170428044737.txt``.


Creating an EC2 cluster
=======================

#. Create a file named ``~/.aws/credentials`` that contains your
   AWS credentials:

   .. code-block:: bash

      [default]
      aws_access_key_id = your-access-key
      aws_secret_access_key = your-secret-key
      region = us-east-1

   NOTE: Replace ``your-access-key``, ``your-secret-key``, and
   ``us-east-1`` with your actual AWS access key ID, your AWS
   secret access key, and your default region. Region is
   optional. For more information about configuring your AWS
   credentials, see the `Boto documentation
   <https://boto3.readthedocs.io/en/latest/guide/quickstart.html#configuration>`_.

#. Create a cluster on EC2 by running:

   .. code-block:: bash

      adam ec2 -n mycluster up --keyname my_keypair --keypair ~/.ssh/my_keypair.pem

   NOTE: Replace "mycluster" with the name you wish to give the new cluster.
   Replace "my_keypair" with the keyname on the EC2 console. Replace
   ``~/.ssh/my_keypair.pem`` with the path to the keypair that matches the
   keyname.

   ``keyname`` and ``keypair`` are required.

   OPTIONAL: You can also specify the AMI, number of nodes,
   instance types and more. To see the available options,
   run ``adam ec2 up --help``:

   .. code-block:: bash

      $ adam ec2 -n 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.


Installing platform components
==============================

After creating or :doc:`provisioning a cluster <../user-guide/tasks/clusters/provision-cluster>`,
you can install platform components by running::

    adam [platform-component] -n [cluster-name] install

EXAMPLE: To install Repository, Enterprise Notebooks, and Scale
on a cluster named "cluster":

.. code-block:: bash

   $ adam repository -n cluster install
   $ adam enterprise-notebooks -n cluster install
   $ adam scale -n cluster cluster install
   $ adam scale -n cluster dask install


Opening a platform component
============================

To open a platform component's user interface in your browser, run::

   adam [platform-component] -n [cluster-name] open

EXAMPLE: To open Repository and Enterprise Notebooks on a
cluster named "cluster":

.. code-block:: bash

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

For more information see :doc:`../user-guide/tasks/work-with-platform-components`.


Removing an EC2 cluster
=======================

To remove an EC2 cluster and terminate the corresponding instances:

#. Run::

     adam ec2 -n [cluster-name] destroy

#. When prompted, type ``y``.

EXAMPLE: To remove the cluster named "cluster":

.. code-block:: bash

    $ adam ec2 -n cluster destroy
    Are you sure you want to destroy the cluster cluster?
    [y/N]: y
