This is a very neat way of mapping sites to backends.
Unfortunately this method has a single downside:
Some sites have one or many domains that need to map to the same backend and while we can have multiple backends point to the same server this will lead to lots of backends.
This would affect hosting / multisite deployments most.
HAProxy maps
This uses a mapping file where domain and backend are listed:
#domainname backendname
example.com be_default
The advantage of this method is that you can define n:n mappings between domains and backends and it likely fits better with the current method of handling HAProxy.
A word on flexibility
Ansible can be a pain to manage large lists of sites. A non-functional requirement may be to enable a way to use the role to easily add a site specific configuration to a managed HAProxy instance.
This way adding a single site doesn't have to run through a playbook with possibly hundreds of sites; This also leaves the management of the loadbalancer up to another application
Based on the documentation here: https://www.haproxy.com/blog/how-to-map-domain-names-to-backend-server-pools-with-haproxy/
Currently we support the "ACL list mapping" based on the SNI host. While this configuration is created using Ansible, it can be pretty cumbersome.
We will refer to this mode as the "classic mapping"
There are 2 other modes possible:
Direct mapping
We could support mapping the right backend based on the hostname / and or port combination:
This is a very neat way of mapping sites to backends. Unfortunately this method has a single downside: Some sites have one or many domains that need to map to the same backend and while we can have multiple backends point to the same server this will lead to lots of backends. This would affect hosting / multisite deployments most.
HAProxy maps
This uses a mapping file where domain and backend are listed:
The advantage of this method is that you can define n:n mappings between domains and backends and it likely fits better with the current method of handling HAProxy.
A word on flexibility
Ansible can be a pain to manage large lists of sites. A non-functional requirement may be to enable a way to use the role to easily add a site specific configuration to a managed HAProxy instance. This way adding a single site doesn't have to run through a playbook with possibly hundreds of sites; This also leaves the management of the loadbalancer up to another application