slzdevsnp
12/6/2019 - 5:12 PM

[digital_ocean] #cloud #vm #digitalocean

[digital_ocean] #cloud #vm #digitalocean

automating droplet creation of vm in digital ocean

plan

  • prepare scripts setup.sh and install.sh
  • create a droplet on Digital Ocean site
  • run scripted packages installation

scripts

Create scripts install.sh and setup.sh in folder e.g. /../cor/infra/digitalocean/bare-ubuntu-droplet Go to that folder. Contents of setup.sh

#!/bin/bash

# IP ADDRESS as CMD PARAM 
MASTER_IP=$1
# 0. COPYING THE FILES
scp install.sh root@${MASTER_IP}:

# 1. executing the installation script
ssh root@${MASTER_IP} bash /root/install.sh

Contents of install.sh

#!/bin/bash
apt-get update 
apt-get upgrade -y 
# install system tools
apt-get install -y bzip2 gcc git htop screen htop vim wget tmux
#install additional packages 
apt-get install -y python3 python3-pip
apt-get upgrade -y bash  # upgrades bash if necessary
apt-get clean  # cleans up the package index cache
#installing python libraries
conda install -y pandas  #  data analysis package
conda install -y numpy  #  numeric calculation package

create a new droplet

If your account does not have a project, create a project

Create a new droplet * ubuntu 18.04, startier tier 1gb/1cpu 25gbdisk 1TB transfer * london location * select additioanl options Private networking * chose a hostnome

Droplet gets created and shows its public ip address Test the connectivity: ssh -i ~/.ssh/id_rsa root@157.245.226.152

Run scripted packgages installation

Go to /../cor/infra/digitalocean/bare-ubuntu-droplet Run setup.sh with droplet's IP as a first arg to setup.sh bash setup.sh 209.97.190.50