This Terraform project simulates Fault Tolerance (FT) on OpenStack by provisioning a basic web setup with load balancing, anti-affinity, and auto-provisioned infrastructure.
openstack-ft-web/
├── environments/
│ └── dev/
│ ├── main.tf # Top-level config where all modules are declared
│ ├── variables.tf # Variable definitions for dev environment
│ ├── terraform.tfvars # Actual variable values for dev
│ ├── outputs.tf # Consolidated outputs from modules
│ └── ankur-poc.pem # SSH key used for provisioning (replace with your key)
│
│ └── prod/ # For Production env
└── modules/
├── network/ # Creates network + subnet
├── router/ # Creates router and attaches subnet + sets external gw
├── security_group/ # Creates SSH (22) and HTTP (80) rules
├── instance/ # Launches 2 VMs with anti-affinity + floating IPs
├── loadbalancer/ # Sets up Octavia LB, pool, listener
└── provisioner/ # Provisions VMs via SSH using null\_resource
- Creates a custom OpenStack network and subnet
- Adds subnet to router and connects router to external gateway
- Sets up security group with inbound rules for SSH (22) and HTTP (80)
- Defines anti-affinity policy to spread VMs across hosts
- Launches 2 VMs, installs a simple webpage inside each
- Creates a load balancer (Octavia) with listener + pool pointing to the VMs
- Associates a Floating IP to the LB for external access
- Terraform ≥ 1.0
- OpenStack CLI credentials (
clouds.yamlor ENV vars) - A valid OpenStack project with required quotas
- SSH keypair to access instances
- Clone the repo
git clone https://github.com/ankurgautam90/openstack-ft-demo.git
cd openstack-ft-demo/environments/dev
-
Replace SSH Key
- Copy your SSH private key to
ankur-poc.pem - Or edit
main.tf/tfvarsto point to your own key file.
- Copy your SSH private key to
-
Update Variables
-
Edit
terraform.tfvarsto include your:auth_url,username,password,tenant_name,region, etc.- Network/Subnet details if different
-
-
Run Terraform
terraform init terraform plan terraform apply
To delete all created resources:
terraform destroy- This setup demonstrates fault tolerance using anti-affinity + load balancing.
- You can test FT by manually shutting down one instance and confirming webpage is still reachable.
- Webpage is provisioned using
remote-execinprovisionermodule.
Ankur Kumar Github | ankurgautam90 Linkedin | ankurgauti
