الفلاتر
طريقة البحث
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • "كلمتان" تجد العبارة بالضبط.
  • --name أو -x تجد خيارًا.
  • #كلمة تبحث داخل الأوامر فقط.
  • @grep تجد الدروس والمعامل التي تستخدم grep.
  • الفلاتر: cat:network · in:labs · level:rhcsa · ch:8 · root:yes. ضع ! قبل كلمة لاستبعادها. OR بين الكلمات تعني إحداها.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث

الفصل 1الاسم في الدورة: 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 الدروس
  • 2 الأوامر

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

$ مستخدم عادي# بصلاحية root (أو مع sudo)

المهارات في هذا الفصل

  • شرح البنية ككود وكيف يعمل Terraform عبر السحابات

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

تذكّر

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

في العمل

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

كل الأوامر في هذا الفصل