Introduction
The purpose of this article is to show you how to automate the deployment of dSIPRouter using HashiCorp Terraform. We ship a Terraform script with dSIPRouter because we do all of our development and testing against Digital Ocean. Also, we wanted to provide you with an example of how you could implement this for other cloud providers since Terraform has providers for all of the major public clouds and on-premise environments as well.
Assumptions
- You have a Digital Ocean API Key
- You have a SSH Key Pair uploaded to Digital Ocean and you know it’s name
Download Terraform and Setup Environment
For congruency, we will be doing this from Windows, but doing so from Linux should be similar. Please download the following packages (uniformity between OS’s):
- GitBash – https://git-scm.com/download/win
- Terraform – https://www.terraform.io/downloads
You will need to place your terraform.exe or executable in C:\Windows\System32 or /usr/local/bin or /usr/sbin, or adjust your windows host system environment variables to the download location of terraform.exe. To do so do the following:
Right click This PC(MyComputer)
—>properties
—>advanced system settings
—>environment variables
—>system variables
—>path–edit–>new
Get Repository and Setup Terraform Variables
Open a terminal window / command prompt and type the following:
export DIGITALOCEAN_TOKEN=<Digital Ocean token key>
git clone https://github.com/dOpensource/dsiprouter
cd dsiprouter/resources/terraform/do
copy terraform.tfvars.sample terraform.tfvars
terraform init
This will install the Digital Ocean provider since our terraform script is configured to work with Digital Ocean.
Edit the terraform.tfvars file, which sets the values of variables needed by the terraform script.
pvt_key_path="C:/Users/alems/Working/andrew" (adjust using path format, andrew is actually the pvt key)
dsiprouter_prefix="dev"
number_of_environments=1
pub_key_name="andrew"
Once modified, you should have all you need to deploy an instance via Terraform.
Build dSIPRouter Using Terraform
Execute the following commands to build dSIPRouter from the master branch using terraform:
terraform apply
If you want to build from another branch you would pass in the branch variable with the value of the branch like this
terraform apply -var branch=v0.643
This is what it will look like as it starts to build:
This is what it will look like after it’s completed:
You will now be able to login to dSIPRouter using the credentials generated.
Login to dSIPRouter
You can login to dSIPRouter using the dSIPRouter WEB GUI URL and the dSIPRouter GUI Username and dSIPRouter GUI Password generated by the installer. Enjoy!