lavish10 / do-droplet

This repos contains script for autoamating the process of creating a droplet on Digital Ocean

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Digital Ocean Droplet Creation Automation

Create your Droplet from Digital Ocean API

Prerequisite

ensure you have the specified version or above for all the above mentioned tools

Installation

Mac OS

  1. Vagrant
$ brew cask install vagrant
  1. Virtualbox
$ brew cask install virtualbox
  1. Ansible
$ brew install ansible
  1. Vagrant DigitalOcean
$ vagrant plugin install vagrant-digitalocean
  1. Direnv
$ brew install direnv

Make sure to hook direnv into your shell.

If you are using bash shell, then add the following line at the end of the ~/.bashrc file:

eval "$(direnv hook bash)"

If you are using zsh shell, then add the following line at the end of the ~/.zshrc file:

eval "$(direnv hook zsh)"

for other shell, refer here

Note, if you are have spwaned multiple tabs / windows / split of your terminal, whenever you make changes to .envrc ensure to press just enter in all the instances to loaded the updated environment variables into the instance of the terminal window

failing to do will result in undesired output

DigitalOcean

As a first step, setup necessary env variables.

In DigitalOcean,

  1. Follow the instruction here to setup personal token
  2. Follow the instruction here to upload your ssh key to your digital ocean account
  3. $ cp .envrc.sample .envrc
  4. Modify the following configurations as per your credentials
DIGITAL_OCEAN_TOKEN: the token your have created in step 1
DIGITAL_OCEAN_SSH_KEY_NAME: the ssh key you have created in step 2
DIGITAL_OCEAN_PRIVATE_KEY: private_key_file_name (assumption is the file will be located under $HOME/.ssh/private_key_file_name) for which you have uploaded the public key in step 2
  1. Load the env variables
## This command has to be run for every change in .envrc
$ direnv allow .

Additionally, if you are using ZSH shell instead of bash

## Only for ZSH
$ eval "$(direnv hook zsh)"
  1. To create the droplet on Digital Ocean,
$ make provision.basic
  1. To teardown the cluster, execute
$ make destroy
  1. By default, VMs are created with 4vCPUs and 8GB of RAM. To change this use the configuration parameter INSTANCE_TYPE.
## default instance type
INSTANCE_TYPE: s-1vcpu-1gb

## For more info, visit https://developers.digitalocean.com/documentation/changelog/api-v2/new-size-slugs-for-droplet-plan-changes/

Troubleshooting

Issue with Digital ocean authentication

If you face the following issue when issuing make, vagrant commands ,

There was an issue with the JSON response from the DigitalOcean
API at:

Path: /v2/droplets
URI Params: {}

The response JSON from the API was:

Response: Unable to authenticate you

simple source the .envrc file once. ($ source .envrc), also ensure your .envrc configurations are correct or use direnv as mentioned in the Prerequisite

Issue with bcrypt_pbkdf

If you face this issue, probably you are using ssh with passphrase ensure you have configured ssh-agent, for more info refer here

About

This repos contains script for autoamating the process of creating a droplet on Digital Ocean


Languages

Language:HTML 98.9%Language:Shell 0.5%Language:Makefile 0.3%Language:Ruby 0.2%