3.1 KiB
Hetzner HA WordPress
This repository contains scripts and configuration files to set up a highly available (HA) WordPress instance on Hetzner Cloud infrastructure. The aim of this project is to provide a robust and scalable solution for hosting a WordPress website with high availability.
Table of Contents
Features
- High availability setup for WordPress using Hetzner Cloud
- Automated deployment of cloud infrastructure via terraform
- Automated provisioning of the servers with ansible
- Test environment with vagrant
Requirements
Before you begin, ensure you have the following:
- A Hetzner Cloud account and API token
- A recent installation of ansible
- A recent installation of terraform
If you would like to test the ansible provisioning locally, ensure you have the following:
- A recent installation of vagrant
- A recent installation of virtualbox
Deployment
To deploy the cloud infrastructure with terraform, switch into the terraform folder
cd terraform
Export the hcloud token as environment variable
export HCLOUD_TOKEN="<your-hcloud-token>"
Initialize terraform
terraform init
And apply the changes using the production variables
terraform apply -var-file="prod.tfvars"
Testing
To test the provisioning with ansible, vagrant is used.
The secrets are stored in an ansible vault.
Vagrant expects them in a password file vault_pass
in the root of the repo.
This file is not included for obvious reasons.
Please ask the project maintainer if you need the vault password.
Launch the virtualboxes inside the repository root folder
vagrant up
For subsequent tests of the playbook run
vagrant provision
To connect to a specific machine run
vagrant ssh web1
Open Tasks
- Replication of the file system between machines: GlusterFS
- Replication of the database between machine: Using mysql replication
- Provision hcloud server with the cloud init ansible module
- Setup Hetzner Managed certificate for the loadbalancer and set type to https
- Assign the correct static external IP to the loadbalancer
- Add required SSH keys
- Document terraform modules with terraform-docs
Shortcomings which should be addressed in future versions
- Use an external secret provider
- Store the terraform state remote
License
Hetzner HA WordPress is licensed under the MIT License.