This project provides a fully automated setup for deploying a dynamic load balancer and backend services on OpenNebula, leveraging modern tools like:
- Terraform: For resource provisioning.
- Ansible: For software configuration and deployment.
- Docker: For containerization of services.
The solution includes:
- An Apache-based load balancer.
- Configurable backend server nodes.
- Full automation for scaling and configuration.
- Dynamic Scaling: Modify the number of backend nodes via a single Terraform variable.
- Infrastructure as Code (IaC): Reproducible, maintainable, and version-controlled infrastructure setup.
- Automated Configuration Management: Ansible ensures consistent environment setup across all nodes.
- Lightweight Containerization: Docker is used for deploying scalable services.
.devcontainer/
Dockerfile # Dockerfile for building the dev environment
devcontainer.json # Dev container configuration
docker-compose.yml # Docker Compose file for the containerized dev environment
init-iac-dev.sh # Script to initialize SSH keys in the dev container
.github/workflows/
main.yml # GitHub Actions workflow for CI/CD
ansible/
roles/
backend/
tasks/
main_tasks.yml # Backend-specific Ansible tasks
templates/
index.html.j2 # Jinja2 template for backend web content
load_balancer/
tasks/
main_tasks.yml # Load balancer-specific Ansible tasks
templates/
apache # Apache configuration templates
inventory # Ansible inventory file for host management
playbook.yml # Main playbook orchestrating tasks
terraform/
terraform.tf # Terraform configuration for OpenNebula
terraform.tfvars # User-defined variables for Terraform
variables.tf # Terraform variables file
apache.conf.tmpl # Template for Apache load balancer config
README.md # This documentation file
To see the project in action, visit the deployed application in your browser here: Load Balancer or put this command in your terminal:
curl http://147.228.173.116
Before getting started, ensure the following tools are installed on your system:
- Docker: For running the development environment.
- Terraform: For provisioning cloud resources.
- Ansible: For configuring nodes.
git clone https://github.com/VandlJ/iac-loadbalancer-automation.git
cd iac-loadbalancer-automation
terraform init
terraform plan
terraform apply -auto-approve
This initializes, plans and applies confirguration for Terraform.
ansible-playbook -i ansible/inventory ansible/playbook.yml
To scale the number of backend servers, edit the variables.tf file in the Terraform configuration directory. For example:
variable "backend_count" {
default = 3
}
After modifying the variable, reapply the Terraform configuration:
terraform apply -auto-approve