Using Vagrant, Docker and Terraform to Streamline Your Dev and Demo Environments

I recently came back from Portland, OR, where I got to speak at HashiConf. I had a great time at the conference, and also got to tour a little bit of Portland and taste the famous Voodoo donuts:

Mmm #donuts #portland #goodbyediet #sorrynotsorry

A photo posted by Nikhil (@nikhilv2) on

 

My presentation at Hashiconf was on how we at Electric Cloud have used some of HashiCorp’s tools – orchestrated by our own ElectricFlow – to create and share a reusable demo library across the organization from dev, qa and even sales. The overall pattern I spoke about was to find the business problem, determine the requirements and then find a solution that works. For each of the above tools we used, I explained how they addressed the business problem we had at the time, how we got buy-in from various stakeholders in the organization, and how we configured these tools as part of the overall solution.

HashiConf would publish the video recording of my talk soon (for now, help yourself to the slides on Speaker Deck – embedded below). In this post I would explain a bit how we used Terraform for infrastructure as code (a similar outcome could have been achieved using Chef or Puppet.)

Using Terraform to Bootstrap a Wildfly Cluster:

We used Terraform to spin up Wildfly instances, for use as our demo environment.

A Wildfly cluster in Domain mode requires some configuration between the Domain and Host controllers. Our model is described in the picture below- where we deploy to the Domain controller, and users are served off the different hosts.

terraform-wildfly-diagram

Deployment to Wildfly cluster in Domain mode

 

Terraform allowed us to write a definition of what we desired, check it into source control and share it with all interested parties. (Check out our code on GitHub:  https://gist.github.com/nikhilv/74a107af7e44866e3f14)

After coding the Terraform files, we can see a visual representation of the execution plan.

terraform-dag

Terraform execution plan

 

After using Terraform, we appreciated the ability to reproduce the infrastructure, that allowed for fast experimentation while still preserving the building blocks that could be used in the future for other demos.

In order to keep a record of the changes that Terraform makes, an Operator should not use Terraform directly to control Production. Instead, it needs to be executed within a tool that can keep track of history and allow users to accept or reject the proposed changes to infrastructure.

Once Terraform had created the infrastructure, we used ElectricFlow to deploy applications to the Wildfly cluster. One of the statements I made during the presentation that got a lot of responses was to be mindful of the way you use the UI to construct your process – since this work, usually, can not be re-used (with the exception of Cloning). For example, Terraform allows you to define as code a lot of the AWS configuration that you’d normally input via the AWS UI. This makes your configuration documented, checked-in to Source Control, and repeatable. Similarly, for the same benefits, we were using our ElectricFlow DSL for defining our Process as Code – so that our deployment and application processes are also in Source Control and are versioned and reusable. Also, it allows us to clone/scale more quickly (since we only need to copy the code, versus using the UI).


 

You can read more about how we orchestrated additional parts of this puzzle, such as Vagrant and Docker. Also, feel free to check the code samples in my deck above and on GitHub.

Thank you HashiConf for inviting me to speak, and thanks for the great conference and for this AWESOME jacket!

therealnikhil-at-hashiconf

My new favorite jacket!

 

Nikhil Vaze

Nikhil Vaze is a Staff Software Engineer on the Electric Cloud engineering team. He is a full stack engineer and loves to hack on things. You can also find him on github and ask.electric-cloud.com. Nikhil holds a Bachelor of Science in Computer Engineering and Master of Science in Security Informatics from Johns Hopkins University.

Share this:

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe

Subscribe via RSS
Click here to subscribe to the Electric Cloud Blog via RSS

Subscribe to Blog via Email
Enter your email address to subscribe to this blog and receive notifications of new posts by email.