Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add logforward configs for 2.3 haproxy #138

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,30 @@ Set up (the latest version of) [HAProxy](http://www.haproxy.org/) in Ubuntu syst
* `haproxy_default_server_params`: [optional]: Default server backend parameters passed to each backend/listen server.
* `haproxy_default_raw_options`: [default: `[]`]: Additional arbitrary lines to insert in the section

* `haproxy_rings`: [default: `[]`]: Enable ring-buffers, to be used as target for log servers or traces.
* `haproxy_rings.{n}.name`: Creates a new ring-buffer with name <rings.name>
* `haproxy_rings.{n}.description`: Optional description string of the ring. It will appear on CLI. By default, <name> is reused to fill this field.
* `haproxy_rings.{n}.format`: Format used to store events into the ring buffer. (May be on of follow: iso, local, raw, rfc3164, rfc5424, short, priority, timed)
* `haproxy_rings.{n}.maxlen`: The maximum length of an event message stored into the ring, including formatted header. If an event message is longer than <length>, it will be truncated to this length.
* `haproxy_rings.{n}.size`: This is the optional size in bytes for the ring-buffer. Default value is set to BUFSIZE.
* `haproxy_rings.{n}.timeout`: Timeouts list declaration
* `haproxy_rings.{n}.timeout.connect`: Set the maximum time to wait for a connection attempt to a server to succeed.
* `haproxy_rings.{n}.timeout.server`: Set the maximum time for pending data staying into output buffer.
* `haproxy_rings.{n}.server`: Server list declaration
* `haproxy_rings.{n}.server.name`: Custom name of remote server
* `haproxy_rings.{n}.server.address`: Remote server address
* `haproxy_rings.{n}.server.port`: Remote server port
* `haproxy_rings.{n}.server.param`: Specific server directive such as "log-proto" to set the protocol used to send messages.

* `haproxy_logforwards`: [default: `[]`]: Declare one or multiple log forwarding section, haproxy will forward all received log messages to a log servers list.
* `haproxy_logforwards.{n}.name`: Creates a new logforward with name <logforward.name>
* `haproxy_logforwards.{n}.bind`: Used to configure a stream log listener to receive messages to forward. This supports the "bind" parameters found in 5.1 paragraph including those about ssl but some statements such as "alpn" may be irrelevant for syslog protocol over TCP.
* `haproxy_logforwards.{n}.dgram-bind`: Used to configure a datagram log listener to receive messages to forward. Addresses must be in IPv4 or IPv6 form,followed by a port. This supports for some of the "bind" parameters found in 5.1 paragraph among which "interface", "namespace" or "transparent", the other ones being silently ignored as irrelevant for UDP/syslog case.
* `haproxy_logforwards.{n}.backlog`: Give hints to the system about the approximate listen backlog desired size on connections accept.
* `haproxy_logforwards.{n}.maxconn`: Fix the maximum number of concurrent connections on a log forwarder. 10 is the default.
* `haproxy_logforwards.{n}.timeout client`: Set the maximum inactivity time on the client side.
* `haproxy_logforwards.{n}.log`: [ log <address> [len <length>] [format <format>] [sample <ranges>:<sample_size>] <facility> [<level> [<minlevel>]] ]Used to configure target log servers. See more details on proxies documentation. If no format specified, haproxy tries to keep the incoming log format. Configured facility is ignored, except if incoming message does not present a facility but one is mandatory on the outgoing format. If there is no timestamp available in the input format, but the field exists in output format, haproxy will use the local date.

* `haproxy_ssl_map`: [default: `[]`]: SSL declarations
* `haproxy_ssl_map.{n}.state`: [default: `present`]: Whether to ensure the file is present or absent
* `haproxy_ssl_map.{n}.src`: The local path of the file to copy, can be absolute or relative (e.g. `../../../files/haproxy/etc/haproxy/ssl/star-example-com.pem`)
Expand Down
6 changes: 6 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ haproxy_global_ssl_default_server_options: 'no-sslv3'
haproxy_global_nbproc: 1
haproxy_global_option: []

# Logforward section
haproxy_logforwards: []

# Rings section
haproxy_rings: []

# defaults section
haproxy_defaults_log: global
haproxy_defaults_mode: http
Expand Down
4 changes: 4 additions & 0 deletions templates/etc/haproxy/haproxy.cfg.j2
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
global
{% include 'global.cfg.j2' %}

{% include 'logforward.cfg.j2' %}

{% include 'rings.cfg.j2' %}

defaults
{% include 'defaults.cfg.j2' %}

Expand Down
24 changes: 24 additions & 0 deletions templates/etc/haproxy/logforward.cfg.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{% if haproxy_version is version('2.3', '<=') %}
{% for logforward in haproxy_logforwards %}
log-forward {{ logforward.name }}
{% if logforward.bind is defined %}
bind {{ logforward.bind }}
{% endif %}
{%- if logforward.dgram_bind is defined %}
dgram-bind {{ logforward.dgram_bind }}
{% endif %}
{%- if logforward.backlog is defined %}
backlog {{ logforward.backlog }}
{% endif %}
{%- if logforward.maxconn is defined %}
maxconn {{ logforward.maxconn }}
{% endif %}
{%- if logforward.timeout is defined %}
timeout client {{ logforward.timeout }}
{% endif %}
{%- for log in logforward.log %}
log {{ log.address }}{% for param in log.param | default([]) %} {{ param }}{% endfor %}
{% endfor %}

{% endfor %}
{% endif %}
25 changes: 25 additions & 0 deletions templates/etc/haproxy/rings.cfg.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{% for ring in haproxy_rings %}
ring {{ ring.name }}
{% if ring.description is defined %}
description {{ ring.description }}
{% endif %}
{%- if ring.format is defined %}
format {{ ring.format }}
{% endif %}
{%- if ring.maxlen is defined %}
maxlen {{ ring.maxlen }}
{% endif %}
{%- if ring.size is defined %}
size {{ ring.size }}
{% endif %}
{%- if ring.timeout.connect is defined %}
timeout connect {{ ring.timeout.connect }}
{% endif %}
{%- if ring.timeout.server is defined %}
timeout server {{ ring.timeout.server }}
{% endif %}
{%- for server in ring.server %}
server {{ server.name }} {{ server.address }}:{{ server.port }}{% for param in server.param | default([]) %} {{ param }}{% endfor %}
{% endfor %}

{% endfor %}