HostRooster Private Cloud and HashiCorp Terraform – Part 1

HashiCorp’s products are often discussed in DevOps and IaaC. Terraform streamlines on-premises and cloud infrastructure provisioning. Terraform manages HostRooster ‘s Public Cloud and GitHub offered a guide. This post discusses HostRooster  Private Cloud and Terraform.

Terraform automates resource development and management for Private Cloud’s VMware vSphere infrastructure. You may use Terraform to deploy and customize VMs from templates. We’ll adapt this example in a second article.


Terraform is a simple binary on HashiCorp’s website for most OSs. Download and copy it to your PATH directory. Run terraform to test everything.


Files and folders

Infrastructure-as-Code tool Terraform uses essential configuration files. Create We’ll start with one .tf file because Terraform reads all .tf files by default. We’ll file data in a later piece.

We’ll use files to make Terraform operations easy to understand. Names, passwords, and resources (vCenter, cluster, etc.). Production Terraform use is discouraged. The second post improves code.


The providers enable you to set Terraform’s external communication. In our case, the vSphere provider will connect to vCenter. Declaring a provider:


Terraform uses its data structure (you can also express everything in JSON to automate file generation). Data is arranged in blocks (here, a provider block named vsphere) and stored as keys/values.


Now that Terraform can connect to vCenter, we require vSphere information. We need to know the data center, cluster, template, etc., where we’ll create a virtual machine. Data-type blocks will be used.


In the example above, we’re seeking to acquire information about pcc-XXX-XXX-XXX datacenter3113 from datastore pcc-001234 and template UBUNTU. We utilize the data center id to access an object’s information.


The resources will generate and/or manage infrastructure parts. In our example, we’ll use a virtual_machine resource, which creates VMs.


Multiple sub-blocks make this resource complex. First, we’ll name the VM. We detail configuration (Resource pool, datastore, etc.). Virtual devices are configured via the network_interface and disk blocks. The clone sub-block allows you to select a template and set the VM’s OS – OS-specific. Levels use data blocks.

Full example


3…2…1… Ignite

Let’s use our new Terraform config file…


We can use our configuration file to create a virtual machine now. Let’s start by initiating the terraform environment. This downloads vSphere and creates Terraform’s files.



Next, run terraform plan to ensure our configuration file is error-free and to visualize Terraform’s actions.


Before proceeding, examine all plan command output. Errors in the configuration file could remove virtual machines in production. Terraform creates a new resource (a VM) in the scenario below without modifying or deleting anything.


The terraform apply command configures the infrastructure based on the configuration file. First, Terraform executes the plan command and asks for confirmation by typing yes.


Your Private Cloud’s vCenter should show a new virtual machine.


After seeing a Terraform workflow, you may want to test configuration file changes. You can add a virtual drive to your VM by altering its resource block.


Run terraform plan to examine what Terraform will do to reconcile infrastructure state with the configuration file.


If you agree with, terraform action’s proposal, restart terraform and apply to add a new virtual disk.

Clean up

Run terraform destroy to eliminate all resources when you’re done testing and no longer need the infrastructure. You can’t recover your data after using this command.


We’ve shown how to install a virtual machine with Terraform. This taught us plan, apply, and destroy, plus provider, data, and resource. Next, we’ll make this sample more customizable and generic.

Say hello to HostRooster, the ultimate one-stop-shop for all your entrepreneurial needs! From website hosting to freelance services, HostRooster is the platform that puts the power of success in your hands. Think of it as a matchmaker for your dreams and your website – HostRooster connects you with the tools and services you need to bring your ideas to life. No more juggling multiple platforms and providers, HostRooster has got you covered. So why wait? Sign up today and join the ranks of the world’s greatest entrepreneurs. With HostRooster, the sky’s the limit! “Successful people do what unsuccessful people are not willing to do.” – Eric Thomas “Don’t wait for opportunities, create them.” – Anonymous “Success is not final, failure is not fatal: it is the courage to continue that counts.” 

%d bloggers like this: