Sitemap

Step-by-Step Guide to Installing Terraform on AlmaLinux 8 and Rocky Linux 8

5 min readSep 9, 2024

--

Press enter or click to view image in full size
banner image for the topic on how to install terraform on almalinux 8 and rocky linux 8

Servers, networks, and databases are familiar terms to anyone involved in IT infrastructure management.

However, as these systems grow in complexity and scale, traditional manual provisioning and management methods are no longer sufficient or effective. Admins and developers need a more efficient, code-driven approach to infrastructure management.

So how do you define and manage your infrastructure resources?

Terraform, a free tool, enables users to manage and set up infrastructure using code. It is provider-agnostic and allows users to automate various provisioning and management processes through easy-to-read configuration files.

In this tutorial, we will discuss how to install Terraform on Almalinux and Rocky Linux. But before diving into the installation details, let us quickly examine the prerequisites.

The Prerequisites

Before you dive into the installation process, ensure you have the following:

  • You have the wget and unzip installed on your server.
  • A user account with sudo or root privileges
  • Terminal or command line access

Let us now discuss the steps in detail.

Terraform can be installed on AlmaLinux and Rocky Linux using two primary methods:

  • Use the zipped archive
  • Utilize the package in the repository

Each method has its own advantages, and we’ll discuss each method in detail.

Method #1: Install Terraform through the Zipped Archive

We recommend this method for users who prefer a standalone installation or want to install a specific Terraform version. However, note that if you opt for this method, you need to manually update it in the future.

Start by visiting the official Terraform download page.

Under the Operating System section select the Linux tab. The latest version will be pre-selected by default.

Locate the download link for your system architecture and right-click the Download button. For 64-bit systems, it is usually located under the AMD64 section.

Next, choose Copy Link Address (or similar depending on your browser).

Once you have copied the URL, use the wget command to download the Terraform package.

# wget https://releases.hashicorp.com/terraform/1.9.5/terraform_1.9.5_linux_386.zip

Next, select the location for installation. We recommend installing Terraform in a directory within your system’s PATH environment variable. This allows you to run the terraform command from any location in the terminal.

# echo $PATH

In this guide, we will use `/usr/local/bin` for the installation.

Extract the file to the location of your choice. Make sure to include the full zip archive name with the extension when unzipping:

# sudo unzip terraform_1.9.5_linux_386.zip -d /usr/local/bin

Note: The file name will vary depending on the version and system architecture. Be sure to copy the file name after downloading it.

The Terraform directory containing the extracted file will be displayed in the output.

Next, check the Terraform version and confirm the installation by executing the following command:

# terraform -version

The output will display the version of Terraform you installed.

Method #2: Install Terraform Using the Repository Package

We recommend this method if you require easier updates in the future. However, it requires adding a repository to your system.

Get RedSwitches’s stories in your inbox

Join Medium for free to get updates from this writer.

Start by installing the yum-utils package to manage repositories:

# sudo yum install -y yum-utils

Next, add the HashiCorp repository.

The HashiCorp repository is an official software repository provided by HashiCorp, the company behind Terraform. This repository hosts packages and binaries for Terraform, making it easy for users to install and update Terraform on various Linux distributions.

To add the official HashiCorp repository to your system, run the following command:

# yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo

Finally, use the YUM package manager to install Terraform.

# sudo yum -y install terraform

The output confirms that Terraform is installed. You can verify this by executing the terraform -version command to view the installed version.

Conclusion

Installing Terraform on AlmaLinux, and Rocky Linux 8 is straightforward with the methods we've covered.

Whether you choose to use the zip file or the HashiCorp repository, both approaches will set you up with Terraform effectively. By following the steps outlined, you can easily manage and automate your infrastructure using Terraform on these systems.

FAQs

Q. What are software packages in the context of installing Terraform?

Software packages are files that contain all the necessary components to install and run a program. In the case of Terraform, you can get it as a zip file or through a software repository, which simplifies the installation process.

Q. How can Terraform help with a cloud provider like Google Cloud Platform?

Terraform is a tool that allows you to manage and automate your infrastructure across various cloud providers, including Google Cloud Platform. You can define and control your cloud resources using Terraform's configuration files.

Q. What is a terraform plan?

A terraform plan command generates an execution plan, indicating what Terraform will do when you apply the configuration. It helps you preview changes before they are made, ensuring your infrastructure is set up as intended.

Q. What is Terraform used for in building infrastructure?

Terraform is a tool for building and managing infrastructure. It automates the process of setting up and configuring servers, networks, and other resources, making infrastructure management more efficient.

Q. Are there specific software libraries needed for Terraform?

While Terraform itself doesn’t require additional software libraries, it may need specific provider plugins to interact with different cloud platforms or services. These plugins are usually installed automatically when you run Terraform.

Q. Is Terraform an open-source infrastructure tool?

Yes, Terraform is an open-source infrastructure tool. This means its source code is freely available for anyone to use, modify, and distribute.

Q. How do I use dnf config-manager for installing Terraform on Rocky Linux 8.5?

The dnf config-manager is a command used to manage repositories on Rocky Linux 8.5. You can use it to add the HashiCorp repository, which provides Terraform and other software packages for installation.

Q. What should I do if the root partition is full during installation?

If the root partition is full, you may need to free up some space or adjust your partitioning scheme. Ensure you have enough space on your root partition to install Terraform and any other software packages.

Q. How do I reset my root password if needed for installation?

If you need to reset your root password, you typically do this from a recovery mode or using special commands in the terminal. Ensure you follow secure procedures to set a new root password.

Q. What is the yum-utils package, and why is it needed?

The yum-utils package provides additional tools for managing YUM repositories and packages. It is needed for tasks like adding new repositories, which you might use to install Terraform.

Q. Can I install Terraform through the Software Center?

In some Linux distributions, the software center may offer Terraform as a software package. However, using the command-line methods described in this guide is often more reliable for installing the latest version of Terraform.

--

--

RedSwitches
RedSwitches

Written by RedSwitches

RedSwitches: Global hosting provider offering Dedicated Servers, IaaS, Managed Solutions & Smart Servers in 20 locations with latest hardware and networks.