updated haproxy state
This commit is contained in:
parent
1a2e8b109f
commit
0e36358ea8
@ -3,6 +3,8 @@ haproxy:
|
||||
enabled: true
|
||||
packages:
|
||||
- haproxy
|
||||
scripts:
|
||||
- hello_world.lua
|
||||
config:
|
||||
defaults:
|
||||
#log global:
|
||||
|
@ -3,3 +3,22 @@
|
||||
haproxy-pkg:
|
||||
pkg.installed:
|
||||
- pkgs: {{ haproxy.packages }}
|
||||
|
||||
haproxy-script-dir:
|
||||
file.directory:
|
||||
- name: {{ haproxy.config.dir }}/scripts
|
||||
- user: {{ haproxy.config.user }}
|
||||
- group: {{ haproxy.config.group }}
|
||||
- mode: "0700"
|
||||
|
||||
{% for filename in haproxy.scripts %}
|
||||
haprox-script-{{ filename }}:
|
||||
file.managed:
|
||||
- name: {{ haproxy.config.dir }}/scripts/{{ filename }}
|
||||
- source: salt://haproxy/scripts/{{ filename }}
|
||||
- user: {{ haproxy.config.user }}
|
||||
- group: {{ haproxy.config.group }}
|
||||
- mode: "0700"
|
||||
- watch_in:
|
||||
- service: haproxy-service
|
||||
{% endfor %}
|
11
states/haproxy/scripts/hello_world.lua
Normal file
11
states/haproxy/scripts/hello_world.lua
Normal file
@ -0,0 +1,11 @@
|
||||
local args = table.pack(...)
|
||||
|
||||
core.register_service("hello-world", "http", function(applet)
|
||||
local response = "Hello World !"
|
||||
applet:set_status(200)
|
||||
applet:add_header("content-length", string.len(response))
|
||||
applet:add_header("content-type", "text/plain")
|
||||
applet:start_response()
|
||||
applet:send(response)
|
||||
core.Info("test".."blabla")
|
||||
end)
|
@ -4,4 +4,4 @@ haproxy-service:
|
||||
service.running:
|
||||
- name: haproxy
|
||||
- enable: true
|
||||
- restart: true
|
||||
- reload: true
|
@ -35,7 +35,9 @@ listen stats
|
||||
{%- endmacro %}
|
||||
|
||||
global
|
||||
#lua-load /etc/haproxy/hello_world.lua
|
||||
{%- for filename in haproxy.scripts %}
|
||||
lua-load {{ haproxy.config.dir }}/scripts/{{ filename }}
|
||||
{%- endfor %}
|
||||
maxconn 1000
|
||||
stats socket ipv4@127.0.0.1:9990 level admin
|
||||
stats socket /var/run/hap-lb.sock mode 666 level admin
|
||||
@ -56,6 +58,11 @@ defaults
|
||||
{{ admin() }}
|
||||
{%- endif %}
|
||||
|
||||
cache static
|
||||
total-max-size 4095
|
||||
max-object-size 50000
|
||||
max-age 120
|
||||
|
||||
frontend http
|
||||
bind *:80,:::80 v4v6
|
||||
mode http
|
||||
@ -75,6 +82,10 @@ backend {{ name }}
|
||||
{%- if values.handle_head|default(false) %}
|
||||
{{ handle_head() }}
|
||||
{%- endif %}
|
||||
{%- if values.usecache|default(true) %}
|
||||
http-request cache-use static if { path_end .css .js .png .jpg }
|
||||
http-response cache-store static
|
||||
{%- endif %}
|
||||
{%- if values.internal_access|default(false) %}
|
||||
{{ internal_access() }}
|
||||
{%- endif %}
|
||||
@ -90,6 +101,6 @@ listen {{ name }}
|
||||
{%- endif %}
|
||||
default-server inter 3s fall 3
|
||||
{%- for endpoint in values.endpoints %}
|
||||
server {{ endpoint.name }} {{ endpoint.name }}:{{ endpoint.port }} check port {{ endpoint.port }}
|
||||
server {{ endpoint.name }} {{ endpoint.name }}:{{ endpoint.port }} check {{ "backup" if endpoint.backup|default(false) }} port {{ endpoint.port }}
|
||||
{%- endfor %}
|
||||
{% endfor %}
|
||||
|
Loading…
Reference in New Issue
Block a user