diff --git a/states/haproxy/defaults.yaml b/states/haproxy/defaults.yaml index 6708c27..bb1580b 100644 --- a/states/haproxy/defaults.yaml +++ b/states/haproxy/defaults.yaml @@ -56,10 +56,10 @@ haproxy: lib: true - name: scripts/collector.lua lib: false - - name: scripts/weight.lua - lib: false - args: - - 5 + #- name: scripts/weight.lua + # lib: false + # args: + # - 5 - name: scripts/state.lua lib: false args: diff --git a/states/haproxy/templates/haproxy.cfg.j2 b/states/haproxy/templates/haproxy.cfg.j2 index 04a5fc1..d38d37b 100644 --- a/states/haproxy/templates/haproxy.cfg.j2 +++ b/states/haproxy/templates/haproxy.cfg.j2 @@ -18,13 +18,13 @@ http-response return status 403 content-type text/html string "

403 forbidden http-response return status 404 content-type text/html string "

404 not found

" if { status 404 } {%- endmacro -%} -{%- macro httpcheckrules(layer="layer7",inter="2s",fall=5,rise=5) -%}check observe {{ layer }} inter {{ inter }} fall {{ fall }} rise {{ rise }}{%- endmacro -%} +{%- macro httpcheckrules(layer="layer7",inter="1s",fall=5,rise=5) -%}check observe {{ layer }} inter {{ inter }} fall {{ fall }} rise {{ rise }}{%- endmacro -%} -{%- macro httpsslrules() -%}ssl verify none{%- endmacro -%} +{%- macro httpsslrules(h2=False) -%}ssl verify none{{ " alpn h2,http/1.1" if h2 }}{%- endmacro -%} {%- macro httpendpoints(servers=[], check=True, disabled=False) -%} {%- for server in servers %} - server {{ server.name }} {{ server.name }}:{{ server.port }}{{ " " + httpcheckrules(inter=server.inter|default("2s"), fall=server.fall|default(5), rise=server.rise|default(5)) if check }}{{ " " + httpsslrules() if server.ssl|default(False) }}{{ " disabled" if server.disabled|default(False) }}{{ " send-proxy" if server.proxy|default(False) }}{{ " on-marked-down shutdown-sessions on-marked-up shutdown-backup-sessions" if server.killsessions|default(False) }} + server {{ server.name }} {{ server.name }}:{{ server.port }}{{ " " + httpcheckrules(inter=server.inter|default("1s"), fall=server.fall|default(5), rise=server.rise|default(5)) if check }}{{ " " + httpsslrules(server.h2|default(False)) if server.ssl|default(False) }}{{ " disabled" if server.disabled|default(False) }}{{ " send-proxy" if server.proxy|default(False) }}{{ " on-marked-down shutdown-sessions on-marked-up shutdown-backup-sessions" if server.killsessions|default(False) }} {%- endfor %} {%- endmacro -%} diff --git a/states/haproxy/templates/maps/access.j2 b/states/haproxy/templates/maps/access.j2 index 6c0354f..5d3f107 100644 --- a/states/haproxy/templates/maps/access.j2 +++ b/states/haproxy/templates/maps/access.j2 @@ -1,5 +1,7 @@ ## {{ salt['pillar.get']('salt_managed', default='Salt Managed') }} {%- from "haproxy/map.jinja" import net with context %} +{%- if net.ip_networks -%} {%- for network in net.ip_networks %} {{ network }} {%- endfor %} +{%- endif -%}