Skip to content

haproxy::peers does not support stick-table definitions inside the peers block #638

@maxadamo

Description

@maxadamo

Use Case

When running HAProxy in an HA cluster, stick tables need to be shared between peers. Since HAProxy 2.4, stick tables can be declared directly inside the peers block:

peers mycluster
  peer loadbalancer1 192.168.1.10:10000
  peer loadbalancer2 192.168.1.11:10000
  table sticktable1  type ip  size 1m  expire 10s  store http_req_rate(10s)

Currently, haproxy::peers and its template haproxy_peers_block.epp only render the peers <name> header and the peer entries. There is no way to declare table entries inside the block through the module.

Describe the Solution You Would Like

Add an optional $tables parameter to haproxy::peers, accepting a list of hashes, and update haproxy_peers_block.epp to render the corresponding table lines.

Example usage:

haproxy::peers { 'mycluster':
  tables => [
    {
      name   => 'sticktable1',
      type   => 'ip',
      size   => '1m',
      expire => '10s',
      store  => 'http_req_rate(10s)',
    },
  ],
}

Expected output:

peers mycluster
  peer loadbalancer1 192.168.1.10:10000
  peer loadbalancer2 192.168.1.11:10000
  table sticktable1  type ip  size 1m  expire 10s  store http_req_rate(10s)

Describe Alternatives You've Considered

The classic syntax — referencing the peers section from within a backend's stick-table directive — still works and is already supported by the module:

backend my_table
  stick-table type ip size 1m expire 10s store http_req_rate(10s) peers mycluster

However, this requires managing the stick table in the backend rather than centralising it in the peers block, which is the approach recommended in HAProxy 2.4+ documentation.

Additional Context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions