How legnakra/azure_ha_wordpress works
Project type and purpose
• This is an infrastructure‐as‐code and configuration‐management project that automates the deployment of a highly available WordPress environment on Microsoft Azure.
• Terraform is used to provision Azure resources (network, VMs, load balancer, MySQL), and Ansible to configure the VMs (install Docker, deploy WordPress containers, clean up temporary SSH access).
a. Operator workstation
• Scripts/Vault: encrypt.sh / decrypt.sh (Ansible Vault)
• Scripts/Terraform: plan.sh / apply.sh / destroy.sh
• Scripts/Ansible: deploy.sh
b. Terraform provisioning layer
• Azure Subscription (backend state stored in Azure Storage)
• Resource Group
• Virtual Network & Subnets
• Load Balancer (public frontend IP + probe + backend pool)
• Two Virtual Machines (in an availability zone or set)
• Azure Database for MySQL (or VM-based MySQL)
• Network Security Group (initially allows 80, 443; temporarily opens 22)
c. Ansible configuration layer
• Inventories/hosts (with the two VMs’ public IPs)
• Roles:
• docker-install – installs Docker on each VM
• wordpress – pulls and runs WordPress container, links to MySQL endpoint
• Handlers: clean up temporary public IPs and SSH rules
d. Runtime services
• Docker container running WordPress on each VM
• MySQL database service
• Azure Load Balancer distributing HTTP traffic across the two WordPress instances
• DNS record (mariatec.es) pointing to Load Balancer’s public IP
Relationships and data flows
• Operator runs plan.sh → Terraform init & plan → shows diff
• Operator runs apply.sh → Terraform provisions all Azure resources
• Terraform outputs the two VM public IPs and the load balancer VIP
• Operator updates Ansible/inventories/hosts with VM IPs
• Operator runs deploy.sh → Ansible connects via SSH (using SSHPass), runs playbooks
• docker-install role → installs Docker
• wordpress role → deploys WordPress containers, configures DB connection
• handlers → remove public IPs & port-22 rules
• End users browse mariatec.es → DNS → Load Balancer → WordPress VMs → MySQL
Architectural patterns & design principles
• Layered approach: Infrastructure provisioning (Terraform) separated from software configuration (Ansible)
• Immutable infrastructure principle: VMs are configured at provisioning time via playbooks
• Declarative configuration: Terraform .tf files, Ansible YAML playbooks
• Reusable modules: Terraform modules for networking, VMs, load balancer, database, storage
• Idempotent roles: Ansible roles for Docker & WordPress ensure consistent state