Infrastructure as Code - Overview

Status: Active
Last Updated: 2026-01-30
Category: Infrastructure Automation
Prerequisites: kb/basics/, kb/containers/docker-basics
Tags: infrastructure-as-code, iac, automation, ansible, terraform, configuration-management

Summary

Complete learning path for Infrastructure as Code (IaC), from manual server setup through declarative automation with Ansible and Terraform. Teaches "why automate," progression from scripts to proper IaC, and self-hosted infrastructure patterns.

🎯 Learning Philosophy

Manual First, Automate Second:

Manual Setup β†’ Scripts β†’ Ansible β†’ Terraform β†’ GitOps
 (Understand)   (Repeat)  (Config)   (Infra)   (Production)

This directory teaches why infrastructure automation matters before how to implement it. You'll learn manual processes first to understand what you're automating, then progress through increasingly sophisticated automation tools.

πŸ“š Learning Path

Prerequisites: Linux Basics + Docker
         ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  PHASE 1: Manual Infrastructure        β”‚
β”‚  β”œβ”€ Manual server provisioning         β”‚
β”‚  β”œβ”€ Manual configuration               β”‚
β”‚  β”œβ”€ Understanding pain points          β”‚
β”‚  β”œβ”€ When automation helps              β”‚
β”‚  └─ Documentation as code              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  PHASE 2: Shell Script Automation      β”‚
β”‚  β”œβ”€ Server setup scripts               β”‚
β”‚  β”œβ”€ Configuration management via bash  β”‚
β”‚  β”œβ”€ Limitations of shell scripts       β”‚
β”‚  └─ Why proper tools matter            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  PHASE 3: Ansible (Configuration Mgmt) β”‚
β”‚  β”œβ”€ Ansible basics                     β”‚
β”‚  β”œβ”€ Playbooks and roles                β”‚
β”‚  β”œβ”€ Inventory management               β”‚
β”‚  β”œβ”€ Idempotent operations              β”‚
β”‚  └─ Real-world patterns                β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  PHASE 4: Terraform (Infrastructure)   β”‚
β”‚  β”œβ”€ Terraform fundamentals             β”‚
β”‚  β”œβ”€ State management                   β”‚
β”‚  β”œβ”€ Providers (Proxmox, AWS, etc)      β”‚
β”‚  β”œβ”€ Modules and workspaces             β”‚
β”‚  └─ Infrastructure patterns            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  PHASE 5: Advanced Patterns            β”‚
β”‚  β”œβ”€ Cloud-Init for VMs                 β”‚
β”‚  β”œβ”€ Immutable infrastructure           β”‚
β”‚  β”œβ”€ GitOps workflows                   β”‚
β”‚  β”œβ”€ Testing infrastructure             β”‚
β”‚  └─ Production patterns                β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“– Articles in This Directory

🟒 Phase 1: Manual Infrastructure (Understanding)

Why Start Manual?:

  1. manual-server-setup - Complete manual VM/server provisioning

    • Ubuntu Server installation
    • Network configuration
    • User management
    • Package installation
    • Service setup
    • Prerequisites: Linux basics
    • Time: 4-6 hours
    • Resources: [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘] 50% - Test VM
  2. documentation-as-code - Runbooks and documentation

    • Why documentation matters
    • Runbook templates
    • Markdown-based docs
    • Keeping docs in sync with reality
    • Prerequisites: Manual setup experience
    • Time: 2 hours
    • Resources: [β–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘] 20%
  3. why-infrastructure-as-code - The case for automation

    • Pain points of manual ops
    • Benefits of IaC
    • When to automate
    • When NOT to automate
    • Choosing the right tool
    • Prerequisites: Manual experience
    • Time: 1 hour
    • Resources: [β–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘] 10% - Conceptual

🟑 Phase 2: Shell Script Automation (First Steps)

  1. bash-provisioning-scripts - Server setup with bash

    • User creation scripts
    • Package installation scripts
    • Configuration file templates
    • Limitations and problems
    • Prerequisites: Bash scripting
    • Time: 3-4 hours
    • Resources: [β–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘] 40%
  2. from-scripts-to-config-mgmt - Why bash isn't enough

    • Idempotency problem
    • Error handling challenges
    • State management
    • Introduction to declarative tools
    • Prerequisites: Bash scripting experience
    • Time: 2 hours
    • Resources: [β–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘] 20%

🟠 Phase 3: Ansible (Configuration Management)

  1. ansible-basics - Introduction to Ansible

    • What is Ansible
    • Control node + managed nodes
    • SSH-based, agentless architecture
    • First playbook
    • Prerequisites: SSH basics
    • Time: 3-4 hours
    • Resources: [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘] 50%
  2. ansible-inventory - Managing hosts

    • Static vs dynamic inventory
    • Host groups
    • Variables and group_vars
    • Inventory patterns
    • Prerequisites: Ansible basics
    • Time: 2-3 hours
    • Resources: [β–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘] 40%
  3. ansible-playbooks - Ansible playbooks deep dive

    • Playbook structure
    • Tasks and handlers
    • Templates (Jinja2)
    • Variables and facts
    • Conditionals and loops
    • Prerequisites: Ansible basics
    • Time: 4-6 hours
    • Resources: [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘] 60%
  4. ansible-roles - Reusable Ansible roles

    • What are roles
    • Role directory structure
    • Creating custom roles
    • Using Ansible Galaxy
    • Role dependencies
    • Prerequisites: Ansible playbooks
    • Time: 3-4 hours
    • Resources: [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘] 50%
  5. ansible-patterns - Real-world Ansible

    • Web server stack automation
    • Database server provisioning
    • User management across fleet
    • Security hardening playbooks
    • Docker host configuration
    • Prerequisites: Ansible roles
    • Time: 6-8 hours
    • Resources: [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘] 70%

πŸ”΄ Phase 4: Terraform (Infrastructure Provisioning)

  1. terraform-basics - Introduction to Terraform

    • What is Terraform
    • HCL syntax
    • Providers
    • Resources
    • First infrastructure
    • Prerequisites: Infrastructure concepts
    • Time: 4-5 hours
    • Resources: [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘] 60%
  2. terraform-state - State management

    • What is state
    • Local vs remote state
    • State backends (S3, Terraform Cloud)
    • State locking
    • Importing existing resources
    • Prerequisites: Terraform basics
    • Time: 3-4 hours
    • Resources: [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘] 50%
  3. terraform-modules - Reusable infrastructure

    • Creating modules
    • Module inputs/outputs
    • Module registry
    • Versioning modules
    • Module patterns
    • Prerequisites: Terraform basics
    • Time: 4-5 hours
    • Resources: [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘] 60%
  4. terraform-proxmox - Homelab infrastructure with Proxmox

    • Proxmox provider setup
    • Creating VMs with Terraform
    • Networking configuration
    • Cloud-init integration
    • Complete homelab stack
    • Prerequisites: Terraform basics, Proxmox
    • Time: 5-6 hours
    • Resources: [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘] 80%
  5. terraform-workspaces - Multiple environments

    • Dev/staging/prod separation
    • Workspace strategies
    • Variable management per environment
    • Prerequisites: Terraform modules
    • Time: 2-3 hours
    • Resources: [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘] 50%

⚫ Phase 5: Advanced Patterns (Production-Ready)

  1. cloud-init-basics - VM initialization

    • What is Cloud-Init
    • User-data vs meta-data
    • Cloud-config syntax
    • Package installation
    • Running scripts on first boot
    • Prerequisites: Linux basics
    • Time: 2-3 hours
    • Resources: [β–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘] 40%
  2. cloud-init-advanced - Advanced Cloud-Init

    • Network configuration
    • Disk partitioning
    • Cloud-init modules
    • Debugging cloud-init
    • Integration with Terraform
    • Prerequisites: Cloud-init basics
    • Time: 3-4 hours
    • Resources: [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘] 60%
  3. immutable-infrastructure - Immutable servers

    • What is immutable infrastructure
    • Benefits and tradeoffs
    • Packer for image building
    • Deployment strategies
    • Container vs VM immutability
    • Prerequisites: IaC experience
    • Time: 3-4 hours
    • Resources: [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘] 70%
  4. gitops-infrastructure - GitOps for infrastructure

    • GitOps principles
    • Git as source of truth
    • PR-based infrastructure changes
    • Automated testing
    • Rollback strategies
    • Cross-reference: kb/gitops/
    • Prerequisites: Git, IaC tools
    • Time: 4-5 hours
    • Resources: [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘] 70%
  5. testing-infrastructure - Testing IaC

    • Why test infrastructure
    • Terraform plan validation
    • Ansible lint and testing
    • Test-Kitchen for Ansible
    • Terratest for Terraform
    • Prerequisites: IaC proficiency
    • Time: 4-6 hours
    • Resources: [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘] 80%
  6. secrets-in-iac - Managing secrets safely

    • Never commit secrets to Git
    • Ansible Vault
    • Terraform sensitive variables
    • External secret stores (Vault)
    • Environment variables
    • Cross-reference: kb/sysadmin/secrets
    • Prerequisites: IaC basics
    • Time: 3-4 hours
    • Resources: [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘] 60%

πŸ”— What Comes Next?

After mastering IaC:

For Container Orchestration:

For CI/CD Integration:

For Security:

For Observability:

πŸ“Š Resource Requirements

Ansible Control Node:

Terraform Workstation:

Lab Environment:

Learning Time Investment:

πŸ› οΈ Recommended Tool Stack

Essential Tools:

Helpful Tools:

Self-Hosted Alternatives:

πŸ’‘ Pro Tips for IaC

  1. Start Small: Automate one server before automating fleet
  2. Version Everything: Git is mandatory for IaC
  3. Test Locally First: Use VMs before touching production
  4. Idempotency Matters: Run twice, same result
  5. Document Assumptions: What OS? What versions? What prerequisites?
  6. Use Modules/Roles: Don't repeat yourself
  7. Separate Environments: Dev/staging/prod in separate states/inventories
  8. Never Commit Secrets: Use vaults or external secret management
  9. Plan Before Apply: Review changes before execution
  10. Keep It Simple: Complex != Better. Simple and working > Clever and broken

πŸ”„ Common Learning Pitfalls

Pitfall 1: Automating Before Understanding

Pitfall 2: Over-Engineering

Pitfall 3: Not Testing

Pitfall 4: Ignoring Idempotency

Pitfall 5: Hard-Coding Values

Pitfall 6: No Version Control

Pitfall 7: Shared State Without Locking

Pitfall 8: Forgetting Documentation

πŸ”— Related KB Sections

πŸ“ Change Log

2026-01-30


πŸ—οΈ Remember: Infrastructure as Code isn't about toolsβ€”it's about treating infrastructure like software. Version controlled, tested, reviewed, and automated. Start manual to understand, then automate for scale!

Choose Theme

Your selection is saved locally.

Neural Cacophony
Aperture v2
Flux v1
Mosaic Chaos
Nexus v1
Nexus Zest
Prism v2
Synapse