HAProxy
This Ansible Playbook configures an existing virtual machine running within the European Weather Cloud (EWC), to operate as a HAProxy server.
HAProxy is a high-performance, open source load balancer and reverse proxy for TCP and Hypertext Transfer Protocol (HTTP) applications. Users can leverage HAProxy to distribute workloads and improve website and application performance.
Functionality
- Layer 4 TCP and Layer 7 HTTP load balancing.
- Protocol support for HTTP, HTTP/2, gRPC and FastCGI.
- Secure Sockets Layer (SSL) and Transport Layer Security termination.
- Dynamic SSL certificate storage.
- Content switching and inspection.
- Transparent proxying.
- Detailed logging.
- Command-line interface (CLI) for server management.
- HTTP authentication.
- Multithreading.
- URL rewrites.
- Health checking.
- Rate limits.
Prerequisites
-
Install git (version 2.0 or higher )
-
Install python (version 3.9 or higher)
-
Install ansible (version 2.15 or higher)
-
Verify the
ssh-httpsOpenStack Security Group exists in your EWC tenancy💡 You may create Security Groups via this EWC Community Hub Item if pre-required ones are missing.
-
If you plan to configure an existing VM, ensure it meets the minium requirements before moving on to the Usage section below:
- VM Image: Ubuntu 24 or 22
- VM Plan: 4 CPU cores, 8GB RAM, 40GB Disk
- Network: Private
- Security Groups:
ssh-https - Floating IP: Required
Otherwise, provision a new VM with above specifications before continuing (see EWC Getting Started: Provision a VM for details).
Usage
1. Clone the repository
git clone https://github.com/ewcloud/ewc-ansible-playbook-flavours-and-provisioning.git
1.1. Change to the specific Item's subdirectory
cd ewc-ansible-playbook-flavours-and-provisioning/playbooks/haproxy-flavour
1.2. Checkout an specific Item's version
⚠️ Make sure to replace
x.y.zin the command below, with your version of preference.
git checkout x.y.z
2. Download Ansible dependencies
💡 By default, Ansible Roles are installed under the
~/.ansible/rolesdirectory within your working environment.
Download the correct version of the Ansible dependencies, if you haven't done so already:
ansible-galaxy role install --force -r requirements.yml
3. Specify the target host and SSH credentials
Create an inventory file, to specify address/credentials that your local working environment should use to connect to the target VM.
Copy into the file one of the two snippets below, and replace the placeholders (i.e. values enclosed in < > characters):
-
Connecting form within the EWC tenancy's network
# inventory.yml --- ewcloud: hosts: haproxy: ansible_python_interpreter: /usr/bin/python3 ansible_host: <add the IPV4 address of the target host> ansible_ssh_private_key_file: <add the path to local SSH private key file> ansible_user: ubuntu ansible_ssh_common_args: -o StrictHostKeyChecking=no
OR
-
Connecting from outside the EWC tenancy's network
⚠️ This requires an SSH Bastion to be already provisioned within your EWC tenancy.
# inventory.yml --- ewcloud: hosts: target: ansible_host: <add the IP address of the target host> ansible_ssh_user: ubuntu ansible_ssh_private_key_file: <add the path to local SSH private key file> ansible_python_interpreter: auto all: vars: ansible_ssh_common_args: >- -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ProxyCommand="ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o BatchMode=yes -W %h:%p -i <add the path to local SSH private key file> cloud-user@<add the IP address of the ssh bastion>"
4. Configure and apply the template
By running the following command, you can trigger an interactive session that prompts you for the necessary user inputs, and then applies changes to your target EWC environment:
ansible-playbook -i inventory.yml haproxy-flavour.yml
Dependencies
💡 Upon execution, a SBOM (SPDX format) is auto-generated and stored in the VM's file system root directory (see
/sbom.json).
| Name | Home URL |
|---|---|
| ewc-ansible-role-haproxy | https://github.com/ewcloud/ewc-ansible-role-haproxy |
Operation
Checkout the following how-to guides to learn about management of the Item after initial setup: