updated haproxy state
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Paul 2024-03-22 10:10:29 +01:00
parent 54132a9baa
commit 668a7df8ae
3 changed files with 25 additions and 21 deletions

View File

@ -31,7 +31,7 @@ haproxy:
countries: countries:
FR: OK FR: OK
dbs: dbs:
- name: /var/lib/haproxy/geoip/GeoLite2-City.mmdb GeoLite2-City.mmdb:
url: https://git.paulbsd.com/paulbsd/GeoLite.mmdb/releases/download/2023.03.26/GeoLite2-City.mmdb url: https://git.paulbsd.com/paulbsd/GeoLite.mmdb/releases/download/2023.03.26/GeoLite2-City.mmdb
lua_max_mem: 1024 lua_max_mem: 1024
peers: peers:
@ -44,25 +44,29 @@ haproxy:
- scripts - scripts
- mods - mods
- errors - errors
geoip_dbs:
scripts: scripts:
- name: mods/haproxy.c haproxy:
path: mods/haproxy.c
lib: true lib: true
- name: scripts/compile.lua compile:
path: scripts/compile.lua
lib: true lib: true
- name: scripts/geoip.lua geoip:
path: scripts/geoip.lua
lib: false lib: false
args: args:
- /var/lib/haproxy/geoip/GeoLite2-City.mmdb - /var/lib/haproxy/geoip/GeoLite2-City.mmdb
- name: scripts/json.lua json:
path: scripts/json.lua
lib: true lib: true
- name: scripts/collector.lua scripts/collector.lua:
lib: false lib: false
#- name: scripts/weight.lua #- name: scripts/weight.lua
# lib: false # lib: false
# args: # args:
# - 5 # - 5
- name: scripts/state.lua state:
path: scripts/state.lua
lib: false lib: false
args: args:
- 30 - 30

View File

@ -25,11 +25,11 @@ haproxy-config-{{ dir }}-dir:
- mode: "0700" - mode: "0700"
{% endfor %} {% endfor %}
{% for file in haproxy.config.scripts %} {% for script, params in haproxy.config.scripts.items() %}
haproxy-script-{{ file.name }}: haproxy-script-{{ script }}:
file.managed: file.managed:
- name: {{ haproxy.config.dir }}/{{ file.name }} - name: {{ haproxy.config.dir }}/{{ params.path }}
- source: salt://haproxy/{{ file.name }} - source: salt://haproxy/{{ params.path }}
- user: {{ haproxy.config.user }} - user: {{ haproxy.config.user }}
- group: {{ haproxy.config.group }} - group: {{ haproxy.config.group }}
- mode: "0600" - mode: "0600"
@ -37,11 +37,11 @@ haproxy-script-{{ file.name }}:
- service: haproxy-service - service: haproxy-service
{% endfor %} {% endfor %}
{% for file in haproxy.config.geoip.dbs %} {% for dbname, params in haproxy.config.geoip.dbs.items() %}
haproxy-geoip-{{ file.name }}: haproxy-geoip-{{ dbname }}:
file.managed: file.managed:
- name: {{ file.name }} - name: /var/lib/haproxy/geoip/{{ dbname }}
- source: {{ file.url }} - source: {{ params.url }}
- skip_verify: True - skip_verify: True
- makedirs: True - makedirs: True
- user: {{ haproxy.config.user }} - user: {{ haproxy.config.user }}

View File

@ -95,9 +95,9 @@ global
maxconn 1000 maxconn 1000
lua-prepend-path {{ haproxy.config.dir }}/mods/?.so cpath lua-prepend-path {{ haproxy.config.dir }}/mods/?.so cpath
lua-prepend-path {{ haproxy.config.dir }}/scripts/?.lua lua-prepend-path {{ haproxy.config.dir }}/scripts/?.lua
{%- for script in haproxy.config.scripts %} {%- for script,params in haproxy.config.scripts.items() %}
{%- if not script.lib and script.enabled|default(true) %} {%- if not params.lib and params.enabled|default(true) %}
lua-load {{ haproxy.config.dir }}/{{ script.name }} {% if "args" in script.keys() %}{{ script.args|join(" ") }}{% endif %} lua-load {{ haproxy.config.dir }}/{{ params.path }} {% if "args" in params.keys() %}{{ params.args|join(" ") }}{% endif %}
{%- endif %} {%- endif %}
{%- endfor %} {%- endfor %}
{%- if haproxy.config.api.enable %} {%- if haproxy.config.api.enable %}
@ -173,7 +173,7 @@ frontend fe_http from {{ haproxy.config.namespace }}
http-request return status 200 content-type text/html lf-string "host: %H\ndate: %[var(txn.httpdate)]\nsrchash: %[var(txn.srchash)]\n" if self_host path_info http-request return status 200 content-type text/html lf-string "host: %H\ndate: %[var(txn.httpdate)]\nsrchash: %[var(txn.srchash)]\n" if self_host path_info
{%- if haproxy.config.geoip.enabled %} {%- if haproxy.config.geoip.enabled %}
# GeoIP ## GeoIP
{{ geoip() }} {{ geoip() }}
{%- endif %} {%- endif %}
@ -230,7 +230,7 @@ frontend fe_https from {{ haproxy.config.namespace }}
http-request deny deny_status 429 if max_req_rate !internal http-request deny deny_status 429 if max_req_rate !internal
{%- if haproxy.config.geoip.enabled %} {%- if haproxy.config.geoip.enabled %}
# GeoIP ## GeoIP
{{ geoip() }} {{ geoip() }}
{%- endif %} {%- endif %}