How to install Terraform on Rocky Linux

How To Install Terraform On Rocky Linux 8

In this short article we will discuss how to install Terraform on Rocky Linux 8 operating system.

Introduction

In today’s rapidly evolving IT landscape, managing infrastructure manually can be time-consuming and error-prone. Terraform, an open-source infrastructure as code (IaC) tool developed by HashiCorp, offers a solution to this challenge. In this article, we will explore what Terraform is, its core concepts, and how it simplifies infrastructure management through automation.

What is Terraform?

Terraform is a powerful tool that allows users to define and provision infrastructure resources using a declarative configuration language. With Terraform, you can describe your desired infrastructure state in code, and the tool will automatically create and manage the resources required to achieve that state. This approach makes infrastructure management more consistent, efficient, and reproducible.

Key Concepts of Terraform

Infrastructure as Code (IaC): Terraform embodies the IaC principle, where infrastructure is managed using code rather than manual processes. This allows for version control, collaboration, and automation.

Providers: Terraform supports various cloud and on-premises providers, such as AWS, Azure, Google Cloud, VMware, and more. Each provider offers a set of resources that can be provisioned and managed using Terraform.

Resources: Resources represent the infrastructure components you want to manage, such as virtual machines, networks, storage, and more. Each resource is defined in the Terraform configuration file.

Terraform Configuration Language (HCL): Terraform uses its own configuration language called HCL (HashiCorp Configuration Language). HCL is designed to be human-readable and allows you to define infrastructure resources, variables, and expressions.

State Management: Terraform maintains a state file that records the current state of the managed infrastructure. The state file is used to plan and apply changes to the infrastructure, ensuring that only necessary modifications are made.

Installing Terraform on Rocky Linux 8 Operating System

Installing Terraform on Rocky Linux is a straightforward process. You can use the package manager DNF (Dandified Yum) to install Terraform from the official HashiCorp repository. Here are the steps:

Step 1: Update System Packages
Step 2: Download Terraform Archive File
Step 3: Extract Terraform Archive File And Move It To /usr/local/bin/
Step 4: Verify Terraform Installation

Step 1: Update System Packages

Before installing any new software, it’s a good practice to update the system packages. Open a terminal and run the following command:

$ sudo dnf update

Step 2: Download Terraform Archive File

By using wget command, we will download the latest Terraform archive file to the system. The latest version of Terraform is version 1.5.3. We will submit the following command :

 https://releases.hashicorp.com/terraform/1.5.3/terraform_1.5.3_linux_386.zip

Output :

[ramansah@infodiginet ~]$ wget https://releases.hashicorp.com/terraform/1.5.3/terraform_1.5.3_linux_386.zip
--2023-07-25 10:21:41--  https://releases.hashicorp.com/terraform/1.5.3/terraform_1.5.3_linux_386.zip
Resolving releases.hashicorp.com (releases.hashicorp.com)... 13.35.166.58, 13.35.166.61, 13.35.166.16, ...
Connecting to releases.hashicorp.com (releases.hashicorp.com)|13.35.166.58|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 19670532 (19M) [application/zip]
Saving to: ‘terraform_1.5.3_linux_386.zip’

terraform_1.5.3_linux_386.z 100%[==========================================>]  18.76M  1.64MB/s    in 6m 16s  

2023-07-25 10:28:06 (51.1 KB/s) - ‘terraform_1.5.3_linux_386.zip’ saved [19670532/19670532]

Step 3: Extract Terraform Archive File And Move It To /usr/local/bin/

Then we will extract Terraform archive file and move it ot /usr/local/bin directory, by submitting command line :

$ sudo unzip terraform_1.5.3_linux_386.zip

Output :

[ramansah@infodiginet ~]$ sudo unzip terraform_1.5.3_linux_386.zip
Archive:  terraform_1.5.3_linux_386.zip
  inflating: terraform            
[ramansah@infodiginet ~]$ sudo mv terraform /usr/local/bin/

Step 4: Verify Terraform Installation

After the installation is complete, verify that Terraform is installed correctly by checking its version:

$ terraform -v

Output :

[ramansah@infodiginet ~]$ terraform -v
Terraform v1.5.3
on linux_386

If it wass successfully installed, we will check it by submitting terraform commands as follow :

$ terraform

Output :

[ramansah@infodiginet ~]$ terraform
Usage: terraform [global options] <subcommand> [args]

The available commands for execution are listed below.
The primary workflow commands are given first, followed by
less common or more advanced commands.

Main commands:
  init          Prepare your working directory for other commands
  validate      Check whether the configuration is valid
  plan          Show changes required by the current configuration
  apply         Create or update infrastructure
  destroy       Destroy previously-created infrastructure

All other commands:
  console       Try Terraform expressions at an interactive command prompt
  fmt           Reformat your configuration in the standard style
  force-unlock  Release a stuck lock on the current workspace
  get           Install or upgrade remote Terraform modules
  graph         Generate a Graphviz graph of the steps in an operation
  import        Associate existing infrastructure with a Terraform resource
  login         Obtain and save credentials for a remote host
  logout        Remove locally-stored credentials for a remote host
  metadata      Metadata related commands
  output        Show output values from your root module
  providers     Show the providers required for this configuration
  refresh       Update the state to match remote systems
  show          Show the current state or a saved plan
  state         Advanced state management
  taint         Mark a resource instance as not fully functional
  test          Experimental support for module integration testing
  untaint       Remove the 'tainted' state from a resource instance
  version       Show the current Terraform version
  workspace     Workspace management

Global options (use these before the subcommand, if any):
  -chdir=DIR    Switch to a different working directory before executing the
                given subcommand.
  -help         Show this help output, or the help for a specified subcommand.
  -version      An alias for the "version" subcommand.

After the installation process is complete and successful, then we can explore other things to help us understand how Terraform works as a tool for DevOps.

Conclusion

We have successfully installed Terraform on Rocky Linux 8 operating system. With Terraform installed, we can now create, manage, and update infrastructure as code using the Terraform configuration language. Make sure to check for updates to keep our Terraform installation up-to-date with the latest features and bug fixes. Enjoy using Terraform to automate your infrastructure provisioning and management tasks!

(Visited 125 times, 1 visits today)

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

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