How dushyantkhobragade/terraform_foreman_vm_creation works
Project Type and Purpose
• This is an IaC/automation project built with Terraform.
• Its sole purpose is to read VM metadata from a CSV file (vms.csv) and automate VM creation in Foreman via the terraform-coop/foreman provider.
File Structure and README
• Top-level files:
• main.tf – Terraform configuration (provider, credentials, CSV path, resources)
• vms.csv – Input metadata for each VM (FQDN, hostgroup ID, CPU count, memory)
• README.md – Describes prerequisites, Terraform workflow, and provider usage
• No nested modules or separate frontend/backend directories imply a single-component automation workflow.
Main Components
a. Developer Workstation
• Contains Terraform CLI, main.tf, and vms.csv
• Runs terraform init/validate/plan/apply
b. Terraform Core
• Reads main.tf & vms.csv
• Manages plugin lifecycle, state file, and execution plan
c. Foreman Provider Plugin
• terraform-coop/foreman/0.7.0, downloaded from the public registry during terraform init
d. Foreman Server
• Exposes API endpoints for provisioning hosts
• Requires credentials (username/password or token)
• Hosts network services (DNS, DHCP, PXE)
e. Public Terraform Registry
• Source for provider plugin
f. CSV Metadata Source (vms.csv)
• Tabular VM definitions used by the Terraform resource block
Relationships and Data Flows
• Terraform CLI → (init) → Public Registry: downloads foreman provider plugin
• Terraform CLI ← (reads) main.tf & vms.csv
• Terraform Core → (HTTP/HTTPS API calls) → Foreman Server
• Authentication with credentials
• Create VM resources in specified hostgroups
• Foreman Server → (response) → Terraform Core
• Terraform Core → (state file) → Local filesystem (for tracking created resources)
Architectural Patterns and Principles
• Modular separation: Terraform Core vs. Provider Plugin vs. Target System
• Declarative resource management: vms.csv + main.tf define desired state
• Idempotence: Terraform plan/apply cycles ensure predictable provisioning