AMP AMP

How to install Terraform on Rocky Linux 9.3

To Install Terraform On Rocky Linux 9.3

Terraform is a program used to build infrastructure automatically—without accessing a cloud provider's console. Terraform can automatically build, update, and destroy infrastructure. It can create various resources: virtual machines, users, network devices, and security components. It enables a person to work with multiple cloud providers (AWS, Azure, Google, etc...) and on-premises systems (VMware, KVM, Proxmox) and much more.

Installation Procedure:

Step 1: Check the OS version by using the below Command.

[root@linuxhelp ~]# cat /etc/os-release
NAME="Rocky Linux"
VERSION="9.3 (Blue Onyx)"
ID="rocky"
ID_LIKE="rhel centos fedora"
VERSION_ID="9.3"
PLATFORM_ID="platform:el9"
PRETTY_NAME="Rocky Linux 9.3 (Blue Onyx)"
ANSI_COLOR="0;32"
LOGO="fedora-logo-icon"
CPE_NAME="cpe:/o:rocky:rocky:9::baseos"
HOME_URL="https://rockylinux.org/"
BUG_REPORT_URL="https://bugs.rockylinux.org/"
SUPPORT_END="2032-05-31"
ROCKY_SUPPORT_PRODUCT="Rocky-Linux-9"
ROCKY_SUPPORT_PRODUCT_VERSION="9.3"
REDHAT_SUPPORT_PRODUCT="Rocky Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="9.3"

Step 2: Install yum-utils package by using the below command

[root@linuxhelp ~]# dnf install -y yum-utils
Rocky Linux 9 - BaseOS                                                                                                                                                        4.2 kB/s | 4.1 kB     00:00
Rocky Linux 9 - BaseOS                                                                                                                                                        1.3 MB/s | 2.2 MB     00:01
Rocky Linux 9 - AppStream                                                                                                                                                     5.5 kB/s | 4.5 kB     00:00
Rocky Linux 9 - AppStream                                                                                                                                                     3.5 MB/s | 7.4 MB     00:02
Rocky Linux 9 - Extras                                                                                                                                                        3.5 kB/s | 2.9 kB     00:00
Dependencies resolved.
==============================================================================================================================================================================================================
 Package                                           Architecture                                   Version                                                Repository                                      Size
==============================================================================================================================================================================================================
Installing:
 yum-utils                                         noarch                                         4.3.0-11.el9_3                                         baseos                                          36 k
Transaction Summary
==============================================================================================================================================================================================================
Install  1 Package

Total download size: 36 k
Installed size: 23 k
Downloading Packages:
yum-utils-4.3.0-11.el9_3.noarch.rpm                                                                                                                                           119 kB/s |  36 kB     00:00
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                          38 kB/s |  36 kB     00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                                      1/1
  Installing       : yum-utils-4.3.0-11.el9_3.noarch                                                                                                                                                      1/1
  Running scriptlet: yum-utils-4.3.0-11.el9_3.noarch                                                                                                                                                      1/1
  Verifying        : yum-utils-4.3.0-11.el9_3.noarch                                                                                                                                                      1/1
Installed:
  yum-utils-4.3.0-11.el9_3.noarch
Complete!

Step 3: Add yum repository by using the below command.

[root@linuxhelp ~]# yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
Adding repo from: https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo

Step 4: Confirm if repository is added and working by using the below command.

[root@linuxhelp ~]# dnf repolist
repo id                                                                                        repo name
appstream                                                                                      Rocky Linux 9 - AppStream
baseos                                                                                         Rocky Linux 9 - BaseOS
extras                                                                                         Rocky Linux 9 - Extras
hashicorp                                                                                      Hashicorp Stable - x86_64

If you can see hashicorp from the list proceed to install terraform.

Step 5: Install terraform by using the below command

[root@linuxhelp ~]# yum -y install terraform
Hashicorp Stable - x86_64                                                                                                                                                     2.6 MB/s | 1.4 MB     00:00
Last metadata expiration check: 0:00:01 ago on Thursday 09 May 2024 03:35:32 AM.
Dependencies resolved.
==============================================================================================================================================================================================================
 Package                                               Architecture                                Version                                               Repository                                      Size
==============================================================================================================================================================================================================
Installing:
 terraform                                             x86_64                                      1.8.3-1                                               hashicorp                                       26 M
Installing dependencies:
 git                                                   x86_64                                      2.39.3-1.el9_2                                        appstream                                       61 k
 git-core-doc                                          noarch                                      2.39.3-1.el9_2                                        appstream                                      2.6 M
 perl-Git                                              noarch                                      2.39.3-1.el9_2                                        appstream                                       37 k
 perl-TermReadKey                                      x86_64                                      2.38-11.el9                                           appstream                                       36 k

Transaction Summary
==============================================================================================================================================================================================================
Install  5 Packages

Total download size: 29 M
Installed size: 101 M
Downloading Packages:
(1/5): perl-TermReadKey-2.38-11.el9.x86_64.rpm                                                                                                                                127 kB/s |  36 kB     00:00
(2/5): perl-Git-2.39.3-1.el9_2.noarch.rpm                                                                                                                                      92 kB/s |  37 kB     00:00
(3/5): git-2.39.3-1.el9_2.x86_64.rpm                                                                                                                                          214 kB/s |  61 kB     00:00
(4/5): git-core-doc-2.39.3-1.el9_2.noarch.rpm                                                                                                                                 2.8 MB/s | 2.6 MB     00:00
(5/5): terraform-1.8.3-1.x86_64.rpm                                                                                                                                           8.4 MB/s |  26 MB     00:03
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                         7.6 MB/s |  29 MB     00:03
Hashicorp Stable - x86_64                                                                                                                                                      29 kB/s | 3.9 kB     00:00
Importing GPG key 0xA621E701:
 Userid     : "HashiCorp Security (HashiCorp Package Signing) <security+packaging@hashicorp.com>"
 Fingerprint: 798A EC65 4E5C 1542 8C8E 42EE AA16 FCBC A621 E701
 From       : https://rpm.releases.hashicorp.com/gpg
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                                      1/1
  Installing       : git-core-doc-2.39.3-1.el9_2.noarch                                                                                                                                                   1/5
  Installing       : perl-TermReadKey-2.38-11.el9.x86_64                                                                                                                                                  2/5
  Installing       : perl-Git-2.39.3-1.el9_2.noarch                                                                                                                                                       3/5
  Installing       : git-2.39.3-1.el9_2.x86_64                                                                                                                                                            4/5
  Installing       : terraform-1.8.3-1.x86_64                                                                                                                                                             5/5
  Running scriptlet: terraform-1.8.3-1.x86_64                                                                                                                                                             5/5
  Verifying        : terraform-1.8.3-1.x86_64                                                                                                                                                             1/5
  Verifying        : perl-TermReadKey-2.38-11.el9.x86_64                                                                                                                                                  2/5
  Verifying        : perl-Git-2.39.3-1.el9_2.noarch                                                                                                                                                       3/5
  Verifying        : git-core-doc-2.39.3-1.el9_2.noarch                                                                                                                                                   4/5
  Verifying        : git-2.39.3-1.el9_2.x86_64                                                                                                                                                            5/5
Installed:
  git-2.39.3-1.el9_2.x86_64           git-core-doc-2.39.3-1.el9_2.noarch           perl-Git-2.39.3-1.el9_2.noarch           perl-TermReadKey-2.38-11.el9.x86_64           terraform-1.8.3-1.x86_64
Complete!

Step 6: Check the version of Terraform to validate our installation by using the below command

[root@linuxhelp ~]# terraform  version
Terraform v1.8.3
on linux_amd64

Conclusion:

We have reached the end of this article. In this guide, we have walked you through the steps required to install Terraform on Rocky Linux 9.3. Your feedback is much welcome.

FAQ
Q
Can I uninstall Terraform from Rocky Linux 9.3?
A
Yes, you can uninstall Terraform using the package manager:
dnf remove terraform
Q
Is there a specific directory structure for Terraform projects?
A
While there's no strict directory structure, it's a common practice to organize Terraform files (.tf) into directories based on the environment or functionality.
Q
Can I upgrade Terraform to the latest version?
A
Yes, you can upgrade Terraform to the latest version using the package manager:
dnf upgrade terraform
Q
How do I check the installed Terraform version?
A
After installation, you can verify the Terraform version using the command:
terraform -v
Q
What is Terraform?
A
Terraform is an open-source infrastructure as code (IaC) tool used for building, changing, and versioning infrastructure efficiently.