The first thing is to execute:

yum update

We check the current repositories in the operating system to see if there is the Hashicorp repository with the command:

yum repolist

which should contain a line like the following if you have the hashicorp repository:

hashicorp                                       Hashicorp Stable - x86_64

and if it is not, add the hashicorp repository where the terraform package is with the command:

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


First we install yum-utils:

sudo yum install -y yum-utils


Once we have installed yum-utils we proceed to install terraform with the command

sudo yum -y install terraform

And we can now check that we have terraform installed by checking the version with:

terraform  version

which will show us the installed version that a priori is the latest, showing something similar to:

Terraform v1.4.1
on linux_amd64

If you want to install another version you can do it by checking the available versions with the command:

yum --showduplicate list terraform

And to install one from the list, execute the following command, substituting the version identifier for the one considered (in this example 1.4.0-1):

sudo yum install terraform-1.4.0-1.x86_64

and if we execute the 'terrraform version' command again, it shows us the following:

[operatorfeitam@dev08 ~]$ terraform version
Terraform v1.4.0
on linux_amd64

Your version of Terraform is out of date! The latest version
is 1.4.1. You can update by downloading from https://www.terraform.io/downloads.html
[operatorfeitam@dev08 ~]$ 

It informs you that it is not the latest version available.


With terraform you can manage your infra legacy or in the cloud by creating the various components that make it up: VMs, networks, etc. And with ansible you can do the same but you could use the latter rather to install and configure your infra services like apache, PostgreSQL, etc.


On other Linux distributions the installation is similar with their package manager, instead of yum.