Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vagrant Installing Anaconda Python?

Anaconda python is installed (in linux) via a bash script. I am trying to use Vagrant provisioning to get Anacaonda Python installed.

In the bash script (following the documentation bootstrap.sh example) I have a bootstrap.sh script that:

  1. wget the install script
  2. chmod +x to make it executable
  3. ./<script>.sh to install.

Installing this way fails as the installation has a few prompts, one of which requires the non-default answer.

Is it possible to automate the installation via a bash script? If not, is it necessary to use something like Puppet? I do not know Puppet at all, so have tried to avoid using...perhaps it is time to dig in?

The end goal is to ship the Vagrantfile and not host a Vagrant box.

P.S. My initial, feeble attempts made use of the linux yes command, but a better way has to exist!

like image 741
Jzl5325 Avatar asked Aug 15 '14 04:08

Jzl5325


2 Answers

In your bootstrap.sh just include something like:

miniconda=Miniconda3-3.7.4-Linux-x86_64.sh
cd /vagrant
if [[ ! -f $miniconda ]]; then
    wget --quiet http://repo.continuum.io/miniconda/$miniconda
fi
chmod +x $miniconda
./$miniconda -b -p /opt/anaconda

cat >> /home/vagrant/.bashrc << END
# add for anaconda install
PATH=/opt/anaconda/bin:\$PATH
END

The -b option runs in batch mode and is what you are looking for:

>>>> ./Miniconda-3.7.0-Linux-x86_64.sh -h 
usage: ./Miniconda-3.7.0-Linux-x86_64.sh [options]

Installs Miniconda 3.7.0

    -b           run install in batch mode (without manual intervention),
                 it is expected the license terms are agreed upon
    -f           no error if install prefix already exists
    -h           print this help message and exit
    -p PREFIX    install prefix, defaults to /Users/phil/miniconda

I also typically put Miniconda (or a link to it) directly in the "vagrant" where the bootstrap.sh is. That way, you are not downloading from the web during each vagrant up (after init or destroy).

like image 87
Phil Cooper Avatar answered Oct 06 '22 01:10

Phil Cooper


I made a GitHub repository based on Phil Cooper's answer.

https://github.com/tomohiro1221/vagrant-anaconda

like image 28
Tomohiro Koana Avatar answered Oct 06 '22 00:10

Tomohiro Koana