Cloud / IaC · Freelance

Per-Client WordPress Hosting with Packer, Terraform and Ansible

A Makefile toolchain bakes an AMI with Packer, builds shared infrastructure with Terraform, and onboards or removes clients through Ansible-generated Terraform.

  • Packer
  • Ansible
  • Terraform
  • ALB
  • Auto Scaling
  • EFS
  • RDS
  • Route 53

// Overview

Packer with an Ansible provisioner bakes a custom image. A base stack creates the shared ALB, listeners, log bucket and IAM. A client module adds, per tenant, a host-header rule, auto-scaling attachment, shared file system, MariaDB instance and DNS record. An Ansible role templates a per-client Terraform directory from a subdomain argument; delete reverses it.

// The problem

Fast, repeatable onboarding and offboarding of isolated WordPress sites on elastic infrastructure.

// Flow

Per-Client WordPress Hosting with Packer, Terraform and Ansible flow1. Bake image → 2. Base stack → 3. Onboard client → 4. Template → 5. Client infra → 6. Runtime config → 7. Scale → 8. Offboard01Bake image02Base stack03Onboard client04Template05 · GATEClient infra06Runtime config07Scale08Offboard
  1. Bake imagePacker and Ansible build the AMI
  2. Base stackshared ALB, listeners, logging bucket, IAM
  3. Onboard clientone make command with a subdomain
  4. TemplateAnsible role copies the client Terraform into its own directory
  5. Client infra gatetarget group, host rule, ASG attachment, file system, database, DNS
  6. Runtime configuser data injects the database endpoint
  7. Scalenodes share content on the file system
  8. Offboarddestroy and remove the directory

// Design decisions & guardrails

  • Fixed and repeating infrastructure are split.
  • Separate Terraform state per client limits blast radius.
  • A shared ALB with host-based routing reduces cost.

// Outcome

Client onboarding reduced to a single command.

// Related