8168af663584e3487bb6ba92cc4f9f93bce18abd
Commit Graph

91 Commits

Author SHA1 Message Date
Damian Dabrowski
8168af6635 Deprecate certbot-auto
Certbot-auto is deprecated since 2020[1] and it is no longer available
under https://dl.eff.org/certbot-auto.
This change removes certbot-auto from haproxy_server role leaving
distro method as the only available option.
[1] https://community.letsencrypt.org/t/certbot-auto-deprecated-explanation-and-solutions/139821
Change-Id: Ibe0f13fc7308359d337fb382cb72998befb90d84
2023年04月26日 16:47:58 +02:00
Damian Dabrowski
a5f285c51e Simplify haproxy_service_configs structure
For historical reasons the ``haproxy_service_configs`` variable was
a list of nested mappings with only single valid key for the top
level mapping.
There have been no use-cases for extra keys, so this patch simplifies
the code by removing one level of nesting.
Change-Id: I50c17b7020a459ab8a88b004cc8828cac857f1c9
2023年03月16日 14:19:22 +01:00
Jonathan Rosser
d548b7e5ff Add support for haproxy map files
HAProxy supports the use of map files for selecting backends, or
a number of other functions. See [1] and [2].
This patch adds the key `maps` for each service definition allowing
fragments of a complete map to be defined across all the services,
with each service contributing some elements to the overall map file.
The service enabled/disabled and state flags are observed to add and
remove entries from the map file, and individual map entries can also
be marked as present/absent to make inclusion conditional.
[1] https://www.haproxy.com/blog/introduction-to-haproxy-maps/
[2] https://www.haproxy.com/documentation/hapee/latest/configuration/map-files/syntax/
Change-Id: I755c18a4d33ee69c42d68a50daa63614a2b2feb7
2023年03月16日 13:17:39 +01:00
Jonathan Rosser
42d80464af Allow default_backend to be specified
Currently default_backend for a service is always set to the
haproxy_service_name for a service, but this might not be what is
required for some configurations.
This patch allows haproxy_default_backend to be configured for
a service to customise the default_backend setting.
Depends-On: https://review.opendev.org/c/openstack/openstack-ansible-rabbitmq_server/+/876436
Change-Id: I9e2be37cb27a33350577a93f23b69e560493b320
2023年03月06日 11:56:51 +00:00
Zuul
044d65e9bb Merge "Accept both HTTP and HTTPS also for external VIP during upgrade" 2023年03月01日 00:27:41 +00:00
Damian Dabrowski
a30ecbee08 Accept both HTTP and HTTPS also for external VIP during upgrade
In change [1] we have added functionality to accept both HTTP and
HTTPS during an upgrade.
However it's only limited to internal VIP. I see no reason not to
implement this also for external VIP. Some people may find it useful.
[1] https://review.opendev.org/c/openstack/openstack-ansible-haproxy_server/+/829899
Change-Id: I672016b75d4b514d87dbb47119ff549bbc4e923e
2023年02月21日 15:23:40 +00:00
Jonathan Rosser
f7c87fd118 Add a variable to allow extra raw config to be applied to all frontends
Currently this must be configured on a per-frontend basis through
service.haproxy_frontend_raw. This patch adds a new role default
variable haproxy_frontend_extra_raw which will be combined with all
per service raw config lines.
Change-Id: I506d46d64df93bbb9e6d1ebfa3d3caa44c80fdd5
2023年02月14日 18:55:00 +00:00
Andrew Bonney
445b15f9c3 Fix dict object key error when haproxy interfaces not defined
The ternary options appear to be getting evaluated whether they
are used or not, so item['interface'] is always accessed.
This patch aims to check for the key's presence before performing
ternary operations, or use Ansible variables to postpone evaluation
until absolutely necessary.
Change-Id: Ib1462c04d1a0820a37998f989e2ed16566f71f54
2023年01月11日 11:03:31 +00:00
Zuul
fd3ba428d9 Merge "Fix warnings in haproxy config" 2022年12月10日 12:16:23 +00:00
Dmitriy Rabotyagov
6532898a3c Make use of haproxy_rise and haproxy_fall variables
At the moment for some reason we're not taking into account default
variables haproxy_rise/haproxy_fall but instead trying to count
based on amount of backends. This makes quite little sense to
depend amount of backend rechecks on amount of backends overall,
so we're chaning behaviour to pre-defined variables that already exist.
Change-Id: I1e53a997f6f443718ea2c6bdfbe8a0b98c44896d
2022年12月09日 15:44:29 +01:00
Damian Dabrowski
34ac0710c5 Fix warnings in haproxy config
Haproxy config check(/usr/sbin/haproxy -c -f /etc/haproxy/haproxy.cfg)
returns 3 warnings:
1. keyword 'forceclose' is deprecated in favor of 'httpclose', and will
not be supported by future versions.
2. backend 'galera-back' : 'option tcplog' directive is ignored in
backends.
3. 'http-request' rules ignored for backend 'galera-back' as they
require HTTP mode.
This change fixes 1. and 2.
Fixing 3. will be a bit more tricky as it's a part of
`openstack_haproxy_stick_table` defined in
/opt/openstack-ansible/inventory/group_vars/haproxy/haproxy.yml
Change-Id: Idaa4b5580039857435f90416924dee26a702deba
2022年12月01日 16:41:04 +00:00
Dmitriy Rabotyagov
6025eaac36 Allow do disable SSL only for stats frontend
Currently there is no way of disabling SSL connection for stats frontend
as it implies more global variable. However, for some systems consuming
self-signed root certificate might be not an option and disabling
SSL verification tricky. Thus, we introduce new variable that allows to
nicely control if SSL should be served for stats frontend or not.
Change-Id: Ic4bc4393ec89469876e9e95b12bb9c4069972713
2022年10月05日 11:29:50 +00:00
Zuul
a502817a89 Merge "Allow haproxy to bind on the interface" 2022年09月27日 21:11:49 +00:00
Zuul
c1df0a5b56 Merge "Add variable for setting certbot domains option" 2022年09月20日 16:03:26 +00:00
Danila Balagansky
1664c993b6 Add variable for setting certbot domains option
Add `haproxy_ssl_letsencrypt_domains` variable, which
contains a list (defaults to `external_lb_vip_address`)
for `--domains` certbot option.
Change-Id: I2ebfff9eeb5279a3964b8578a6e66aa132d763f5
2022年09月15日 08:03:07 +00:00
Dmitriy Rabotyagov
901523ddbb Allow haproxy to bind on the interface
In some user scenarious (like implementing DNS RR) it might be useful to
bind on 0.0.0.0 but at the same time do not conflict with other services
that are binded to the same ports. For that, we can specify a specific
interface, on which haproxy will be binded to 0.0.0.0.
In netstat it would be represented like `0.0.0.0%br-mgmt:5000`.
With that we also allow to fully override `vip_binds` if assumtions
that role make are not valid for some reason.
Change-Id: Ic4c58ef53abc5f454b6fbebbd87292a932d173ae
2022年08月09日 18:47:29 +00:00
Jonathan Rosser
06e76706c7 Allow customisation of stick-tables for each service.
A new variable "haproxy_stick_table" is added which allows a custom
stick-table to be supplied that is used as the default stick-table
for all haproxy back-ends.
In addition, the variable service.haproxy_stick_table can be defined
for each service to allow a unique stick-table to be supplied for
a particular service.
The old default stick-table definition is removed as there was no
use case defined for it in this role before. An example is added
to defaults/main.yml to show how the custom stick-table can be used
to rate-limit requests that generate 4xx responses which commonly
occur during vulnerability scanning or credential stuffing attacks.
There are many other uses for stick-tables, consult the HAProxy
documentation for details.
Change-Id: I50daba08c10f071157d6450ea2fa97df448f99ec
2022年07月11日 14:54:01 +00:00
Dmitriy Rabotyagov
be9a66c280 Don't restrict haproxy tunable options
Instead of hardcoding specific supported tunable options, we
just pass key as an option to haproxy config.
This change might break deployments during upgrades, since format of
values in variable has changed, but appropriate release note was written
We also increase maxrewrite by default, as otherwise usage of CSP leads
to 500 error.
Change-Id: I949960420ed5dbd6d58f0de7dae0ac629a85b7fc
Related-Bug: https://github.com/haproxy/haproxy/issues/1597
Needed-By: https://review.opendev.org/c/openstack/openstack-ansible-os_horizon/+/844815 
2022年06月20日 08:27:40 +02:00
JamesGibo
d30bb2e6d1 Add functionality to accept both HTTP and HTTPS during upgrade
Enable TLS on internal communication has 2 parts
* Enabling TLS on the internal VIPs for haproxy frontends
* Enabling TLS on the service backends
Haproxy has support for enabling TLS on frontends and backends,
but doing so would cause downtime.
In the case of upgrading frontends, enabling TLS would prevent
openstack services from working until their config is changed
from http to https, as they do not follow redirects.
In the case of backends haproxy would mark each backend as down
because if could not initiate a HTTPS connection to the backend
until the backend is updated.
This patch fixes this and allows haproxy to accept both HTTP and
HTTPS on the same well known port for each service. It also
allows for both HTTP and HTTPS backends.
Support for HTTP and HTTPS on the frontend is enabled by setting
haproxy_tcp_upgrade_frontend: true
Support for HTTP and HTTPS on the backend is enabled by setting
haproxy_tcp_upgrade_backend: true
This is a temporary patch and will be removed once instances have
been upgraded to HTTPS for internal communications in a future
release of OSA.
Change-Id: I4279005d5b4e6133cf85ba43379b51149c838f17
2022年02月18日 14:40:14 +00:00
Zuul
ab0c91f810 Merge "Adjust default configuration to support TLS v1.3" 2022年01月28日 18:56:35 +00:00
Andrew Bonney
0aeaeb590a Adjust default configuration to support TLS v1.3
This adds TLS v1.3 support to the HAProxy role by default, along
with a new variable to manage cipher suites.
The old variable for TLS v1.2 and below ciphers is renamed for
consistency, but is still supported as a default where overridden
by deployments.
Depends-On: https://review.opendev.org/c/openstack/openstack-ansible/+/823943
Change-Id: Iaf9709ac5f5ac8db281a9ec7278cef274186ba15
2022年01月10日 08:57:40 +00:00
James Gibson
92dac326a9 Add default CA store to use when haproxy_backend_ca is true
If haproxy_backend_ca set to true, default to using system CA
so you dont have to specify the exact CA to use.
Change-Id: I536c32a0b152a2b754787e07574472ecfaebd7e7
2021年12月15日 14:06:25 +00:00
James Gibson
33dbb82bbb Add option to force encryption of all health checks over SSL
This is required if a server only speaks HTTPS
Change-Id: Ib99eed929dfded2bbf11bc1a54c4184edafe8452
2021年12月06日 17:22:43 +00:00
Zuul
f8b7ce18a2 Merge "Fix inconsistency in haproxy_frontend_raw naming" 2021年11月22日 18:30:50 +00:00
James Gibson
9b1fd69588 Remove httplog directive from backends as ignored
Option httplog directive is ignored in backends
http://cbonte.github.io/haproxy-dconv/2.0/configuration.html#4-option%20httplog
Change-Id: I792f22b8e20b3ca34be78a9c87ca0f1050f9225c
2021年11月12日 10:46:47 +00:00
Dmitriy Rabotyagov
afa12fbc97 Fix inconsistency in haproxy_frontend_raw naming
We have announced and documented haproxy_frontend_raw variable
while in fact introduced haproxy_raw. Since announced variable name
better reflects its purpose and it was announced,
we rename it to haproxy_frontend_raw in template generation.
Change-Id: I7ba9588b599f42dddad395df1a2e18ccfe6b3fe3
2021年11月12日 12:29:57 +02:00
Dmitriy Rabotyagov
1195355b43 Fix haproxy Let's Encrypt SSL path
With releasing PKI role we broke Let's Encrypt option because of
changing directories where certs should be located
and not reflecting these changes for let's encrypt. At the same time
we should not generate self-signed cert when let's encrypt path is used.
Depends-On: https://review.opendev.org/c/openstack/openstack-ansible/+/811742
Closes-Bug: #1938961
Change-Id: I1a6701b171782528373bc1d0a39e70e6d1ef20ab
2021年10月05日 15:08:40 +01:00
Andrew Bonney
964a33558b Add configuration option for native prometheus exporter
HAProxy added native Prometheus support from v2.0. This can be
enabled using the existing stats endpoint via an additional
/metrics path.
Change-Id: If9528969c7915db06138c0746dc419d8302f0e7c
2021年07月30日 09:07:50 +01:00
Zuul
1dc4fa621c Merge "Generate self-signed SSL per listen IP" 2021年06月25日 17:21:17 +00:00
Dmitriy Rabotyagov
f14ba91798 Generate self-signed SSL per listen IP
We're providing an option to have an IP address per VIP
address. Currently it's used only for creating self-signed
SSLs signed with internal CA per each VIP. With follow-up
patches that will also allow to provide user certificates
per VIP, making possible to cover internal and external
endpoints with different non-wildcard certs.
Change-Id: I0a9eb7689eb42b50daf5c94c874bb7429b271efe
2021年06月25日 13:30:25 +00:00
James Gibson
3139772435 Add variable to disable stick-table
In some use cases you may want to define your own stick-table and
rules, this can be done using the backend_arguments variables.
As you can have only one stick-table per backend or frontend
the default stick-table needs to be disabled.
I am also not convinved the default stick-table is used for anything,
it just logs requests and never uses the logs, i think it could be
removed.
Depends-On: https://review.opendev.org/c/openstack/openstack-ansible/+/797819
Change-Id: I54307c00673ababb277257f2bb0e456e3e011ac4
2021年06月24日 11:53:32 +01:00
Dmitriy Rabotyagov
f058cf8d61 Replace whitelist with allowlist naming
Change-Id: I568273d0ef1d5ee391a42981e66cc9895b9d71b6
2021年06月16日 14:40:19 +03:00
Jonathan Rosser
ca76349e9f Use http-request set-header instead of reqadd
This is needed for HAProxy 2.1 which is in Debian Bullseye
Change-Id: I912c6d810acc137c3b3e73dc40160d6376cb3884
2021年05月13日 16:08:50 +00:00
Andrew Bonney
357daad5c8 Allow HAProxy stats to be pinned to one or more processes
When HAProxy is run in multi-process mode, the single stats page
shows metrics for one of the processes at a time, with a random
selection made on page reload.
Whilst a more complete solution may be to enable a stats page for
each process, this is a little cumbersome. This addition allows
the stats page to be pinned to one process, providing a partial
snapshot of the state of the instance.
Change-Id: Id9314e5b267aafeaf34c82874eb8bfe0713dfac3
2021年03月25日 14:08:15 +00:00
Marc Gariepy
ca2c011cf2 Add haproxy_frontend_only and haproxy_raw feature.
you can add prometheus metric exposed directly via haproxy if your
version is recent enough.
https://www.haproxy.com/blog/haproxy-exposes-a-prometheus-metrics-endpoint/
Change-Id: I10e7220071290301a85409a1f74fcbad2743d19d
2020年12月14日 19:10:29 +00:00
Danny Meloy
8120c9a3c5 Add haproxy_backend_only flag to service template
Addition of a `haproxy_backend_only` flag to the service template
for instances in which a frontend service uses ACLs to propgate
requests to multiple backend services, and not all backend services
require a corresponding frontend. This should prevent the
proliferation of spurious frontend services.
Change-Id: I8c419be82cffd289ffcc5086afac923d6eb1a78a
2020年09月01日 11:14:55 +00:00
Zuul
1dc605c4aa Merge "Allow backend healthcheck interval to be overridden per service" 2020年05月07日 18:54:54 +00:00
Zuul
1d65b887c6 Merge "Use a certbot pre-hook to ensure haproxy backend is up before renewal" 2020年05月07日 18:54:51 +00:00
Zuul
17108e96e5 Merge "Add option to use distro provided certbot package" 2020年05月07日 18:52:51 +00:00
Jonathan Rosser
449aa69edc Allow frontend acl to be undefined.
Change-Id: I0ca01db61b88024e609ccd4fe991ed56f81db19d
2020年05月07日 15:17:07 +01:00
Jonathan Rosser
342aee0402 Allow backend healthcheck interval to be overridden per service
Different services may require different check intervals
Change-Id: Ia7361825dffe073f6361503f6e3c15ddb15d7944
2020年05月07日 13:16:42 +00:00
Jonathan Rosser
dbc8fe1fe2 Use a certbot pre-hook to ensure haproxy backend is up before renewal
We use the built in python3 http server to bring up a temporary backend
on the node which wants to renew a certificate. The timeout set so that
the haproxy health check has noticed the backend come up before certbot
runs.
There is otherwise a race condition between the haproxy healthcheck and
the certbot challenge request arriving at the acme-challenge endpoint.
Change-Id: I2f5f9457c43c68f2881bf9d44f43434ca7b43859
2020年05月07日 13:15:54 +00:00
Jonathan Rosser
1d386a57f5 Add option to use distro provided certbot package
This patch allows a certbot package from a distro repository to be
used instead of the certbot-auto script. For ubuntu the distro package
takes care of setting up all the necessary directories in /etc/letsencrypt
and creates a systemd service for running the renewal. This avoids
needing to manage those aspects of the installation in this ansible role.
Change-Id: If7c5bcde299362bb3d2a136db659ca319e22e35b
2020年05月07日 13:13:47 +00:00
Jonathan Rosser
ba3a89944b Allow multiple methods of installing certbot
Currently the only method is by downloading the certbot-auto script
and executing that. Some distros supply a so this patch sets up
an option for a future patch to add distro package support
Change-Id: Ie32e6f577c9aa898906ee76199fd0ebe75d5ae95
2020年05月05日 14:01:23 +00:00
Jonathan Rosser
f35867466c Add extra controls for frontend redirects
This patch adds two new variables for a service:
* haproxy_redirect_scheme
This variable allows a custom string to be specified to override
the default condition used to redirect http to https.
* haproxy_frontend_acls
This variable works in the same way as haproxy_acls except it applies
the acl to the frontend rather than the backend configuration. This
can be required when some paths are not redirected to https but must
instead be handled by a specific backend.
Change-Id: I6b13375ba738d7659681ca773297d0b6b0fd7efb
2020年04月23日 19:32:06 +01:00
Zuul
e33fa5065b Merge "Add server specific backend options" 2020年03月12日 15:08:37 +00:00
Georgina Shippey
04857cad3d Add server specific backend options
Ability to add per server backend options to backend nodes.
For example if adding cookies for persistance:
haproxy_service_configs:
 ...
 - service:
 haproxy_service_name: serviceX
 ...
 haproxy_backend_nodes:
 - name: serverA
 ip_addr: 192.168.1.1
 backend_server_options:
 - "check cookie serverA"
 - name: serverB
 ip_addr: 192.168.1.2
 backend_server_options:
 - "check cookie serverB"
 haproxy_backend_arguments:
 - "cookie SERVERID insert indirect nocache"
 haproxy_backend_server_options:
 - "inter 3000"
 ...
Then the templated out server lines would look like:
server serverA 192.168.1.1 ... inter 3000 check cookie serverA
server serverB 192.168.1.2 ... inter 3000 check cookie serverB
Change-Id: Ief39bd50549c64f5f8d34e143acccf25dbbce299
2020年03月12日 11:37:44 +00:00
Zuul
805673e9e1 Merge "Add options to override which addresses haproxy binds to" 2020年03月02日 17:55:45 +00:00
Magnus Bergman
049b479b65 Add options to override which addresses haproxy binds to
Adding options to be able to override the default behaviour of
haproxy binding to external_lb_vip_address and internal_lb_vip_address.
The default behaviour stays the same after this change.
Change-Id: I76044aea498d73e97087719279ba0a37a9eb28e9
2020年03月02日 14:29:12 +01:00
Magnus Bergman
fc95fa8cdb Add missing X-Forwarded-Prot for extra_lb_tls_vip_addresses
This fixes a missing parameter for the extra_lb_tls_vip_addresses
feature introduced by change 705228.
Change-Id: I8fdbfd2100e84e6344f48c193e9430002102e5fa
2020年02月28日 20:44:05 +01:00