====================
Offline Installation
====================

This section is for installations on machines that do not have access to the 
internet. The air gap archives contain installers, dependencies and packages to 
mirror.

Note: Before proceeding, ensure the 
:doc:`installation requirements <requirements>` are met. 

.. _download-mirror-archive:

Download air gap archive
========================

Download the installers archive and the appropriate mirrors archive for your 
needs. The :doc:`airgap-archive` page lists the archives and their contents.

This document assumes the air gap media is available on the target server at 
`$INSTALLER_PATH`. For example::

    tar xf <installer-archive> -C /installer/
    export INSTALLER_PATH=/installer/anaconda-enterprise-`date +%Y-%m-%d`

Also download and expand the archive of conda packages you plan to mirror. 
Documentation assumes packages are expanded to '$INSTALLER_PATH'::

    tar xf <archive-of-pkgs-to-mirror> -C /installer/
    export MIRRORS_ARCHIVE=/installer/repo-mirrors-`date +%Y-%m-%d`

.. include:: install-common.rst
   :start-after: S_HEADING_MONGO
   :end-before: E_HEADING_MONGO


Change directory to appropriate `rpms*` directory to find dependencies::

    cd $INSTALLER_PATH/rpms*x/

.. include:: install-common.rst
   :start-after: S_MONGO_INSTALL
   :end-before: E_MONGO_INSTALL

.. begin 2. Anaconda Repository admin account

.. include:: install-common.rst
   :start-after: S_AER_ADMIN_ACT
   :end-before: E_AER_ADMIN_ACT

.. begin 3. Install Anaconda Repository section

.. include:: install-common.rst
   :start-after: S_HEADING_INSTALL
   :end-before: E_HEADING_INSTALL

Install Anaconda Repository, following the prompts in the installation routine::

    bash $INSTALLER_PATH/anaconda_repository-*-linux-64.sh

Note: Path should have only one installer that is for the latest stable version 
of anaconda repository.

.. include:: install-common.rst
   :start-after: S_AER_INSTALL
   :end-before: E_AER_INSTALL

.. Sections 4, 5, 6, 7, 8

.. include:: install-common.rst
   :start-after: S_AER_SECTIONS_45678
   :end-before: E_AER_SECTIONS_45678

.. begin section 9. Mirror anaconda and miniconda

.. include:: install-common.rst
   :start-after: S_HEADING_MIRROR_CONDA
   :end-before: E_HEADING_MIRROR_CONDA

.. begin code to mirror installers

Define URL for miniconda installers::

    URL="file://$INSTALLER_PATH/conda/"

Note: Air gap archive only contains the latest version of both Miniconda and 
Anaconda installers.

.. include:: install-common.rst
   :start-after: S_GET_MINICONDA
   :end-before: E_GET_MINICONDA

Download anaconda installers.

.. include:: install-common.rst
   :start-after: S_GET_ANACONDA
   :end-before: E_GET_ANACONDA


.. Section 10

.. include:: install-common.rst
   :start-after: S_HEADING_MIRROR_CHANNELS
   :end-before: E_HEADING_MIRROR_CHANNELS

Since we're mirroring from a local filesystem, some additional configuration is 
necessary. The steps are the same for each channel:

1. Create a mirror config yaml typically stored in `$PREFIX/etc/anaconda-server/mirror/`
2. :doc:`Customize configuration <mirrors-sync-configuration>`. An example is 
   if you only need to mirror packages for a subset of platforms. By default, 
   it mirrors all packages found in the channels: linux-64, osx-64, win-64, 
   win-32, linux-32.
3. Invoke the mirror command by pointing it to the config file

Create config::

    echo "channels:" > ~/repo/etc/anaconda-server/mirror/conda.yaml
    echo "  - file://$MIRRORS_ARCHIVE/anaconda-suite/pkgs" >> \
           ~/repo/etc/anaconda-server/mirror/conda.yaml

Mirror the default anaconda packages::
    
    anaconda-server-sync-conda --mirror-config ~/repo/etc/anaconda-server/mirror/conda.yaml


:doc:`Mirror anaconda repository <mirrors-anaconda-repository>` contains 
documentation and advanced yaml config for mirroring other channels.
