Filters
Zo zoek je
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • "twee woorden" vindt precies die zin.
  • --naam of -x vindt een optie.
  • #woord zoekt alleen in commando's.
  • @grep vindt lessen en labs die grep gebruiken.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Zet ! voor een woord om het weg te laten. OR tussen woorden betekent één ervan.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken

Hoofdstuk 1Naam in de cursus: Objective 1: Infrastructure as Code (IaC) with Terraform

Understand Infrastructure as Code and Terraform

Infrastructure as Code (IaC) means: servers, networks and cloud services are described in text files, kept in Git, reviewed like code, and built by a tool. Terraform is the most used IaC tool that works with almost every cloud and service.

  • 5 Lessen
  • 2 Commando's

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

$ als gewone gebruiker# als root (of met sudo)

Vaardigheden in dit hoofdstuk

  • IaC uitleggen en hoe Terraform over clouds heen werkt

1.1

Know what IaC is

Instead of clicking in a portal, you write the wanted state in files. A tool compares it with reality and makes the changes.

By handWith IaC
Steps in a wiki, done differently each timeThe same files give the same result every time
No history of who changed whatGit history, pull requests, reviews
Hard to rebuild after a disasterRebuild the whole environment with one command
Test and production drift apartOne code base, different variables per environment

Onthoud

Terraform is declarative: you describe what you want (3 VMs, one VNet), not how to create it. Terraform works out the order and the steps.

1.2

Know the advantages of IaC

IaC makes infrastructure faster, safer and cheaper to change.

  • Repeatable: dev, test and prod from the same code.
  • Reviewable: every change is a pull request with a plan.
  • Documented: the code is the documentation.
  • Testable: format, validate, scan for security problems before anything changes.
  • Recoverable: rebuild after a disaster or a mistake.
  • Cost control: destroy test environments every evening, create them again in the morning.

1.3

See how Terraform works with many platforms

Terraform talks to each platform through a provider (a plugin). The same language and workflow work for Azure, AWS, Google Cloud, Kubernetes, GitHub, DNS services, and hundreds more.

main.tf
terraform {
  required_providers {
    azurerm = { source = "hashicorp/azurerm", version = "~> 4.0" }
    github  = { source = "integrations/github", version = "~> 6.0" }
  }
}
 
provider "azurerm" {
  features {}
}
 
resource "azurerm_resource_group" "web" {
  name     = "rg-web-dev"
  location = "westeurope"
}
 
resource "github_repository" "infra" {
  name       = "infra-web"
  visibility = "private"
}
CaseHow Terraform helps
Multi-cloudOne tool and one workflow for several clouds
Hybrid cloudCloud resources and on-premises (VMware, network devices) in one plan
Service-agnosticNot only clouds: DNS, monitoring, Git hosting, identity providers

1.4

Compare Terraform with other tools

Each tool has a main job. They are often used together.

ToolMain job
Terraform / OpenTofuCreate and change infrastructure (any platform)
ARM / BicepAzure only (lesson)
CloudFormationAWS only
AnsibleConfigure servers (packages, files, services)
PackerBuild VM images

Op het werk

A common pattern: Packer builds the image, Terraform creates the VMs and network, Ansible (or cloud-init) configures what runs inside.

1.5

Install Terraform

Terraform is one binary. Install it from the HashiCorp repository.

dnf install -y dnf-plugins-core
dnf config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
dnf install -y terraform
terraform version
terraform -install-autocomplete

Alle commando's in dit hoofdstuk