From 29411a15a57841a7446e4b075e0e4e9b6c39d618 Mon Sep 17 00:00:00 2001 From: Jeremy Hanmer Date: Tue, 27 Oct 2020 12:30:49 -0700 Subject: [PATCH 1/3] support hash-type configuration option --- README.md | 2 ++ templates/etc/haproxy/backend.cfg.j2 | 3 +++ templates/etc/haproxy/listen.cfg.j2 | 3 +++ 3 files changed, 8 insertions(+) diff --git a/README.md b/README.md index ece1d8d6..7c1f090f 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,7 @@ Set up (the latest version of) [HAProxy](http://www.haproxy.org/) in Ubuntu syst * `haproxy_listen.{n}.bind_process`: [optional]: Limits the declaration to a certain set of processes numbers (e.g. `[all]`, `[1]`, `[2 ,3, 4]`) * `haproxy_listen.{n}.mode`: [optional]: Set the running mode or protocol of the section (e.g. `http`) * `haproxy_listen.{n}.balance`: [required]: The load balancing algorithm to be used (e.g. `roundrobin`) +* `haproxy_listen.{n}.hash-type`: [optional]: The hashing type to be used for balancing (e.g. `consistent`) * `haproxy_listen.{n}.maxconn`: [optional]: Fix the maximum number of concurrent connections * `haproxy_listen.{n}.source`: [optional]: Set the source address or interface for connections from the proxy * `haproxy_listen.{n}.option`: [optional]: Options to set (e.g. `[dontlog-normal]`) @@ -301,6 +302,7 @@ Set up (the latest version of) [HAProxy](http://www.haproxy.org/) in Ubuntu syst * `haproxy_backend.{n}.stick`: [optional]: Stick declarations * `haproxy_backend.{n}.stick.{n}.table`: [required]: Configure the stickiness table for the current section (e.g. `type ip size 500k`) * `haproxy_backend.{n}.stick.{n}.stick_on`: [optional]: Define a request pattern to associate a user to a server (e.g. `src`) +* `haproxy_backend.{n}.hash-type`: [optional]: The hashing type to be used for balancing (e.g. `consistent`) * `haproxy_backend.{n}.no_option`: [optional]: Options to unset (e.g. `[forceclose]`) * `haproxy_backend.{n}.no_log`: [optional, default `false`]: Used when the logger list must be flushed. For example, if you don't want to inherit from the default logger list * `haproxy_backend.{n}.tcp_check`: [optional]: Perform health checks using tcp-check send/expect sequences (e.g. `['expect string +OK\ POP3\ ready']`) diff --git a/templates/etc/haproxy/backend.cfg.j2 b/templates/etc/haproxy/backend.cfg.j2 index 3f059bbb..3d1e86f3 100644 --- a/templates/etc/haproxy/backend.cfg.j2 +++ b/templates/etc/haproxy/backend.cfg.j2 @@ -46,6 +46,9 @@ backend {{ backend.name }} {% for timeout in backend.timeout | default([]) %} timeout {{ timeout.type }} {{ timeout.timeout }} {% endfor %} +{% if backend.hash-type is defined %} + hash-type {{ hash-type }} +{% endif %} {% for action in ['reqadd', 'rspadd'] %} {% for params in backend[action] | default([]) %} {{ action }} {{ params.string }}{% if params.cond is defined %} {{ params.cond }}{% endif %} diff --git a/templates/etc/haproxy/listen.cfg.j2 b/templates/etc/haproxy/listen.cfg.j2 index 457c358c..8cda4de8 100644 --- a/templates/etc/haproxy/listen.cfg.j2 +++ b/templates/etc/haproxy/listen.cfg.j2 @@ -16,6 +16,9 @@ listen {{ listen.name }} {% if listen.balance is defined %} balance {{ listen.balance }} {% endif %} +{% if listen.hash-type is defined %} + hash-type {{ hash-type }} +{% endif %} {% if listen.maxconn is defined %} maxconn {{ listen.maxconn }} {% endif %} From 81f66f2f4e4054c47fea7cd9dc93dcc1cd55276e Mon Sep 17 00:00:00 2001 From: Jeremy Hanmer Date: Tue, 27 Oct 2020 12:35:06 -0700 Subject: [PATCH 2/3] cleanup --- templates/etc/haproxy/backend.cfg.j2 | 2 +- templates/etc/haproxy/listen.cfg.j2 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/etc/haproxy/backend.cfg.j2 b/templates/etc/haproxy/backend.cfg.j2 index 3d1e86f3..d027de43 100644 --- a/templates/etc/haproxy/backend.cfg.j2 +++ b/templates/etc/haproxy/backend.cfg.j2 @@ -47,7 +47,7 @@ backend {{ backend.name }} timeout {{ timeout.type }} {{ timeout.timeout }} {% endfor %} {% if backend.hash-type is defined %} - hash-type {{ hash-type }} + hash-type {{ backend.hash-type }} {% endif %} {% for action in ['reqadd', 'rspadd'] %} {% for params in backend[action] | default([]) %} diff --git a/templates/etc/haproxy/listen.cfg.j2 b/templates/etc/haproxy/listen.cfg.j2 index 8cda4de8..b3afbfad 100644 --- a/templates/etc/haproxy/listen.cfg.j2 +++ b/templates/etc/haproxy/listen.cfg.j2 @@ -17,7 +17,7 @@ listen {{ listen.name }} balance {{ listen.balance }} {% endif %} {% if listen.hash-type is defined %} - hash-type {{ hash-type }} + hash-type {{ listen.hash-type }} {% endif %} {% if listen.maxconn is defined %} maxconn {{ listen.maxconn }} From 69fc25be5fb110d76aa76030e5f9ff9fee93548c Mon Sep 17 00:00:00 2001 From: Jeremy Hanmer Date: Tue, 27 Oct 2020 13:00:24 -0700 Subject: [PATCH 3/3] cleanup --- README.md | 4 ++-- templates/etc/haproxy/backend.cfg.j2 | 4 ++-- templates/etc/haproxy/listen.cfg.j2 | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 7c1f090f..b03b5a54 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,7 @@ Set up (the latest version of) [HAProxy](http://www.haproxy.org/) in Ubuntu syst * `haproxy_listen.{n}.bind_process`: [optional]: Limits the declaration to a certain set of processes numbers (e.g. `[all]`, `[1]`, `[2 ,3, 4]`) * `haproxy_listen.{n}.mode`: [optional]: Set the running mode or protocol of the section (e.g. `http`) * `haproxy_listen.{n}.balance`: [required]: The load balancing algorithm to be used (e.g. `roundrobin`) -* `haproxy_listen.{n}.hash-type`: [optional]: The hashing type to be used for balancing (e.g. `consistent`) +* `haproxy_listen.{n}.hash_type`: [optional]: The hashing type to be used for balancing (e.g. `consistent`) * `haproxy_listen.{n}.maxconn`: [optional]: Fix the maximum number of concurrent connections * `haproxy_listen.{n}.source`: [optional]: Set the source address or interface for connections from the proxy * `haproxy_listen.{n}.option`: [optional]: Options to set (e.g. `[dontlog-normal]`) @@ -302,7 +302,7 @@ Set up (the latest version of) [HAProxy](http://www.haproxy.org/) in Ubuntu syst * `haproxy_backend.{n}.stick`: [optional]: Stick declarations * `haproxy_backend.{n}.stick.{n}.table`: [required]: Configure the stickiness table for the current section (e.g. `type ip size 500k`) * `haproxy_backend.{n}.stick.{n}.stick_on`: [optional]: Define a request pattern to associate a user to a server (e.g. `src`) -* `haproxy_backend.{n}.hash-type`: [optional]: The hashing type to be used for balancing (e.g. `consistent`) +* `haproxy_backend.{n}.hash_type`: [optional]: The hashing type to be used for balancing (e.g. `consistent`) * `haproxy_backend.{n}.no_option`: [optional]: Options to unset (e.g. `[forceclose]`) * `haproxy_backend.{n}.no_log`: [optional, default `false`]: Used when the logger list must be flushed. For example, if you don't want to inherit from the default logger list * `haproxy_backend.{n}.tcp_check`: [optional]: Perform health checks using tcp-check send/expect sequences (e.g. `['expect string +OK\ POP3\ ready']`) diff --git a/templates/etc/haproxy/backend.cfg.j2 b/templates/etc/haproxy/backend.cfg.j2 index d027de43..f80e149a 100644 --- a/templates/etc/haproxy/backend.cfg.j2 +++ b/templates/etc/haproxy/backend.cfg.j2 @@ -46,8 +46,8 @@ backend {{ backend.name }} {% for timeout in backend.timeout | default([]) %} timeout {{ timeout.type }} {{ timeout.timeout }} {% endfor %} -{% if backend.hash-type is defined %} - hash-type {{ backend.hash-type }} +{% if backend.hash_type is defined %} + hash-type {{ backend.hash_type }} {% endif %} {% for action in ['reqadd', 'rspadd'] %} {% for params in backend[action] | default([]) %} diff --git a/templates/etc/haproxy/listen.cfg.j2 b/templates/etc/haproxy/listen.cfg.j2 index b3afbfad..26c30da2 100644 --- a/templates/etc/haproxy/listen.cfg.j2 +++ b/templates/etc/haproxy/listen.cfg.j2 @@ -16,8 +16,8 @@ listen {{ listen.name }} {% if listen.balance is defined %} balance {{ listen.balance }} {% endif %} -{% if listen.hash-type is defined %} - hash-type {{ listen.hash-type }} +{% if listen.hash_type is defined %} + hash-type {{ listen.hash_type }} {% endif %} {% if listen.maxconn is defined %} maxconn {{ listen.maxconn }}