Terraform is a cloud-agnostic Infrastructure automation tool created by the awesome HashiCorp Engineers to help you with the infrastructure resource management using code. Terraform allows you build, change, and version infrastructure deployed on popular cloud environments and on premise. This short article will show you how to install terraform on CentOS 8 / Rocky Linux 8 Linux system.
Install Terraform on CentOS 8 / Rocky Linux 8
Before you get started ensure you have a sudo user that will be used to install Terraform on CentOS 8 / Rocky Linux 8 Linux machine. Below few steps should work fine for you.
Step 1: Install yum-utils package
We’ll use yum-utils package that will help in adding HashiCorp repository to the system:
sudo yum install -y yum-utils
Step 2: Install Terraform on CentOS 8 / Rocky Linux 8
Next we add CentOS YUM repository:
sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
Confirm repository is added and working:
$ sudo dnf repolist
repo id repo name
appstream CentOS Stream 8 - AppStream
baseos CentOS Stream 8 - BaseOS
centos-advanced-virtualization CentOS-8 - Advanced Virtualization
centos-ceph-nautilus CentOS-8 - Ceph Nautilus
centos-nfv-openvswitch CentOS-8 - NFV OpenvSwitch
centos-openstack-wallaby CentOS-8 - OpenStack wallaby
centos-rabbitmq-38 CentOS-8 - RabbitMQ 38
epel Extra Packages for Enterprise Linux 8 - x86_64
epel-modular Extra Packages for Enterprise Linux Modular 8 - x86_64
extras CentOS Stream 8 - Extras
hashicorp Hashicorp Stable - x86_64
powertools CentOS Stream 8 - PowerTools
If you can see hashicorp from the list proceed to install terraform:
sudo yum -y install terraform
If you wanted to install an older version of Terraform, the HashiCorp Yum repositories contain multiple versions of Terraform:
$ yum --showduplicate list terraform
....
terraform.x86_64 1.2.0-1 hashicorp
terraform.x86_64 1.2.1-1 hashicorp
terraform.x86_64 1.2.2-1 hashicorp
terraform.x86_64 1.2.3-1 hashicorp
terraform.x86_64 1.2.4-1 hashicorp
terraform.x86_64 1.2.5-1 hashicorp
terraform.x86_64 1.2.6-1 hashicorp
terraform.x86_64 1.2.7-1 hashicorp
terraform.x86_64 1.2.8-1 hashicorp
terraform.x86_64 1.2.9-1 hashicorp
terraform.x86_64 1.3.0-1 hashicorp
terraform.x86_64 1.3.1-1 hashicorp
terraform.x86_64 1.3.2-1 hashicorp
terraform.x86_64 1.3.3-1 hashicorp
terraform.x86_64 1.3.4-1 hashicorp
terraform.x86_64 1.3.5-1 hashicorp
Then select a specific version of Terraform, see example:
sudo dnf install terraform-<version>.x86_64
Step 3: Confirm Terraform Installation on CentOS 8 / Rocky Linux 8
Check the version of Terraform to validate our installation:
$ terraform version
Terraform v1.3.5
on linux_amd64
You can then refer to some of the guides we have on using Terraform.
- How to Provision VMs on KVM with Terraform
- Hetzner cloud with Terraform
- How To Provision VMs on oVirt / RHEV with Terraform
- Deploy VM Instances on Hetzner Cloud with Terraform
- Build AWS EC2 Machine Images (AMI) With Packer and Ansible
Other Learning materials include:
- HashiCorp Certified: Terraform Associate
- Learn DevOps: Infrastructure Automation With Terraform
- HashiCorp Certified: Terraform Associate -50 Practical Demos
- Terraform on AWS with SRE & IaC DevOps | Real-World 20 Demos