From cfdeef62a0908ddce882c26c090100e7152b4ecc Mon Sep 17 00:00:00 2001 From: Ingo Bente Date: Wed, 23 Sep 2015 15:05:07 +0200 Subject: [PATCH] adds support for log-format configuration in frontend, listen and defaults --- haproxy/templates/haproxy.jinja | 9 +++++++++ pillar.example | 2 ++ 2 files changed, 11 insertions(+) diff --git a/haproxy/templates/haproxy.jinja b/haproxy/templates/haproxy.jinja index bfe89a2..2c8303d 100644 --- a/haproxy/templates/haproxy.jinja +++ b/haproxy/templates/haproxy.jinja @@ -95,6 +95,9 @@ defaults {%- if 'options' in salt['pillar.get']('haproxy:defaults', {}) -%} {{- render_list_of_dictionaries('option', salt['pillar.get']('haproxy:defaults:options')) }} {%- endif %} +{%- if 'logformat' in salt['pillar.get']('haproxy:defaults', {}) %} + log-format {{ salt['pillar.get']('haproxy:defaults:logformat') }} +{%- endif %} {%- if 'maxconn' in salt['pillar.get']('haproxy:defaults', {}) %} maxconn {{ salt['pillar.get']('haproxy:defaults:maxconn') }} {%- endif %} @@ -152,6 +155,9 @@ listen {{ listener[1].get('name', listener[0]) }} {%- if 'mode' in listener[1] %} mode {{ listener[1].mode }} {%- endif %} + {%- if 'logformat' in listener[1] %} + log-format {{ listener[1].logformat }} + {%- endif %} {%- if 'uniqueidformat' in listener[1] %} unique-id-format {{ listener[1].uniqueidformat }} {%- endif %} @@ -302,6 +308,9 @@ frontend {{ frontend[1].get('name', frontend[0]) }} {%- if 'log' in frontend[1] %} log {{ frontend[1].log }} {%- endif %} + {%- if 'logformat' in frontend[1] %} + log-format {{ frontend[1].logformat }} + {%- endif %} {%- if 'mode' in frontend[1] %} mode {{ frontend[1].mode }} {%- endif %} diff --git a/pillar.example b/pillar.example index 17654b3..3fd9d35 100644 --- a/pillar.example +++ b/pillar.example @@ -39,6 +39,7 @@ haproxy: - dontlognull - forwardfor - http-server-close + logformat: "%ci:%cp\\ [%t]\\ %ft\\ %b/%s\\ %Tq/%Tw/%Tc/%Tr/%Tt\\ %ST\\ %B\\ %CC\\ %CS\\ %tsc\\ %ac/%fc/%bc/%sc/%rc\\ %sq/%bq\\ %hr\\ %hs\\ %{+Q}r" timeouts: - http-request 10s - queue 1m @@ -114,6 +115,7 @@ haproxy: www-https: bind: "*:443 ssl crt /etc/ssl/private/certificate-chain-and-key-combined.pem" + logformat: "%ci:%cp\\ [%t]\\ %ft\\ %b/%s\\ %Tq/%Tw/%Tc/%Tr/%Tt\\ %ST\\ %B\\ %CC\\ %CS\\ %tsc\\ %ac/%fc/%bc/%sc/%rc\\ %sq/%bq\\ %hr\\ %hs\\ %{+Q}r\\ ssl_version:%sslv\\ ssl_cipher:%sslc" reqadd: - "X-Forwarded-Proto:\\ https" default_backend: www-backend