Kit Wai Chan - Fotolia

Tip

Use HashiCorp's Terraform tool and companions for production IaC

Developers want isolated systems for prototyping. Testers want mimicry of production. And IT operations wants to configure this infrastructure for them without reinventing the wheel.

Terraform, Packer and Nomad are straightforward tools that enable DevOps and cloud teams to do their jobs quickly, accurately and with provably correct results.

The Terraform tool and supporting technologies, all from HashiCorp, each perform their own function and work together to produce infrastructure as code (IaC).

For example, Terraform orchestration, Packer provisioning and Nomad management enable a developer new to a project to quickly reproduce the existing test environment on a new, isolated setup. Should things go wrong, it's simple to destroy the configuration and roll it out again, which saves the administrator from getting involved in issues of network, server and OS setup and infrastructure scaling and redundancy.

Terraform basics

Terraforming, a term familiar to any science fiction enthusiast, makes an environment habitable. In the world of cloud computing, administrators use the HashiCorp Terraform tool to create reproducible, versionable builds of a network infrastructure, upon which virtual infrastructure can be placed.

The network infrastructure is described in a domain-specific language, HashiCorp Configuration Language (HCL), which follows a set structure to organize the values for the network. Administrators can share files and build entire environments using that highly transportable file. It's a simple task to build identical test environments, rather than leave developers to suffer with close but inaccurate approximations of the deployment. Revisions are easy to build, roll out and test.

A Terraform file should work without issue on one platform to reproduce the same environment consistently. To deploy in a new environment, such as AWS or Microsoft Azure, Terraform uses the same language for the build, with some different configuration variables for the image.

Terraform orchestration creates the foundation upon which other tools and techniques populate the environment with a high degree of automation.

Packer basics

Once the Terraform tool creates an environment, the user should create VMs to populate it. Packer creates portable machine images, such as packaged VMs.

These images are platform-neutral, which means a user can build images with Packer to deploy on VMware, Oracle VM VirtualBox, AWS and other host environments.

The images are, however, bare-bones in nature. Packer builds an empty VM according to the defined information about platform, size, compute location and other details in the configuration file. Packer usually starts with a base image that includes the OS, then the user can configure the image themselves via shell scripts or integrate to a configuration management and automation tool, such as Chef and Ansible, to set the system up with the right OS configuration features, application, libraries and other components. The smaller these builds are, the more quickly they deploy.

With a VM and deployment environment, there are still operational concerns, such as high availability and scalability. Nomad deals with the complexity.

Nomad basics

Nomad is designed to run jobs, which are tasks fitted with configuration specifics independent of the infrastructure lifecycle in Terraform. Nomad acts as a supervisor for the application deployment. For example, the user can define the application in HCL, and Nomad manages where instances deploy on suitable nodes. If the application requires four front-end instances, then Nomad will ensure that the correct number of instances is running. If a node fails and takes down two of the four front-end instances, Nomad spins up new instances on other nodes to replace it.

The Terraform tool, in combination with Packer and Nomad, gets infrastructure live quicker, with more consistency than manual provisioning. The tool set guarantees a reproducible IT environment on demand. If tools such as Terraform and Packer were not available to run IaC, the scripts and manual work to build environments would add complexity to deployment that could amplify the difficulties of IT operations.

Starting from scratch with these tools takes time, but it pays dividends as you rely increasingly on IaC. Master the Terraform tool and its associated technologies, and you'll view infrastructure components as cattle, not pets.

Dig Deeper on Systems automation and orchestration

Software Quality
App Architecture
Cloud Computing
SearchAWS
TheServerSide.com
Data Center
Close