From 8067c8abd21c318dc130d170eae1fe4cffd17a4e Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Sat, 10 Jun 2023 10:02:59 +0200 Subject: [PATCH] updated haproxy state --- states/haproxy/defaults.yaml | 3 +-- states/haproxy/scripts/state.lua | 7 +++++-- states/haproxy/templates/haproxy.cfg.j2 | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/states/haproxy/defaults.yaml b/states/haproxy/defaults.yaml index d303e16..f1beba4 100644 --- a/states/haproxy/defaults.yaml +++ b/states/haproxy/defaults.yaml @@ -56,7 +56,6 @@ haproxy: - name: scripts/collector.lua lib: false - name: scripts/weight.lua - enabled: false lib: false args: - 5 @@ -67,7 +66,7 @@ haproxy: namespace: paulbsd user: haproxy group: haproxy - servername: "High-performance Web Server 1.0" + servername: FAProxy (Fucking Awesome Proxy) http2: true defaults: #log: global diff --git a/states/haproxy/scripts/state.lua b/states/haproxy/scripts/state.lua index 25819f8..f0c2157 100644 --- a/states/haproxy/scripts/state.lua +++ b/states/haproxy/scripts/state.lua @@ -13,8 +13,11 @@ function create_state() try = try+1 end - local a = io.popen('echo "show servers state" | socat tcp-connect:127.0.0.1:9990 -') - local content = a:read("*a") + local s = core.tcp() + local c = s:connect("127.0.0.1:9990") + local sent = s:send("show servers state\n") + local content,err = s:receive("*a") + s:close() if content ~= nil then if #content>0 then diff --git a/states/haproxy/templates/haproxy.cfg.j2 b/states/haproxy/templates/haproxy.cfg.j2 index e96ebe2..085ca15 100644 --- a/states/haproxy/templates/haproxy.cfg.j2 +++ b/states/haproxy/templates/haproxy.cfg.j2 @@ -151,6 +151,7 @@ frontend https from {{ haproxy.config.namespace }} .endif mode http option httplog + option http-buffer-request {% for name, service in haproxy.config.spoe.items() %} filter spoe engine {{ name }} config {{ haproxy.config.dir }}/spoe.cfg {%- endfor %}