Skip to content

Commit

Permalink
Merge pull request #89 from Oefenweb/pr-88
Browse files Browse the repository at this point in the history
Add support for additional arbitrary lines (raw options)
  • Loading branch information
tersmitten authored Feb 12, 2019
2 parents bd09243 + 489428a commit b5947b7
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Set up (the latest version of) [HAProxy](http://www.haproxy.org/) in Ubuntu syst
* `haproxy_global_peers.{n}.peers`: Peer declarations
* `haproxy_global_peers.{n}.peers.{n}.name`: [required]: Name of the host (recommended to be `hostname`) (e.g. `haproxy1`)
* `haproxy_global_peers.{n}.peers.{n}.listen`: [required]: IP and port for peer to listen/connect to (e.g. `192.168.0.1:1024`)
* `haproxy_global_raw_options`: [default: `[]`]: Additional arbitrary lines to insert in the section

* `haproxy_defaults_log`: [default: `global`]: Enable per-instance logging of events and traffic. `global` should be used when the instance's logging parameters are the same as the global ones. This is the most common usage
* `haproxy_defaults_logformat`: [optional]: Allows you to customize the logs in http mode and tcp mode (e.g. `%{+Q}o\ %t\ %s\ %{-Q}r`)
Expand All @@ -69,6 +70,7 @@ Set up (the latest version of) [HAProxy](http://www.haproxy.org/) in Ubuntu syst
* `haproxy_defaults_compression.{}.name`: [required]: The compression name (e.g. `algo`, `type`, `offload`)
* `haproxy_defaults_compression.{}.value`: [required]: The compression value, (e.g. if name = algo : one of this values `identity`, `gzip`, `deflate`, `raw-deflate` / if name = type : list of mime type separated by space for example `text/html text/plain text/css` / if name = `offload` value is empty)
* `haproxy_default_server_params`: [optional]: Default server backend parameters passed to each backend/listen server.
* `haproxy_default_raw_options`: [default: `[]`]: Additional arbitrary lines to insert in the section

* `haproxy_ssl_map`: [default: `[]`]: SSL declarations
* `haproxy_ssl_map.{n}.src`: The local path of the file to copy, can be absolute or relative (e.g. `../../../files/haproxy/etc/haproxy/ssl/star-example-com.pem`)
Expand Down Expand Up @@ -181,6 +183,7 @@ Set up (the latest version of) [HAProxy](http://www.haproxy.org/) in Ubuntu syst
* `haproxy_listen.{n}.errorfile.{n}.code`: [required]: The HTTP status code. Currently, HAProxy is capable of generating codes 200, 400, 403, 408, 500, 502, 503, and 504 (e.g. `400`)
* `haproxy_listen.{n}.errorfile.{n}.file`: [required]: A file containing the full HTTP response (e.g `/etc/haproxy/errors/400.http`)
* `haproxy_listen.{n}.default_server_params`: [optional]: Default server params applied for each server for this particular listen entry.
* `haproxy_listen.{n}.raw_options`: [default: `[]`]: Additional arbitrary lines to insert in the section

* `haproxy_frontend`: [default: `[]`]: Front-end declarations
* `haproxy_frontend.{n}.name`: [required]: The name of the section (e.g. `https`)
Expand Down Expand Up @@ -270,6 +273,7 @@ Set up (the latest version of) [HAProxy](http://www.haproxy.org/) in Ubuntu syst
* `haproxy_frontend.{n}.errorfile`: [optional]: Errorfile declarations
* `haproxy_frontend.{n}.errorfile.{n}.code`: [required]: The HTTP status code. Currently, HAProxy is capable of generating codes 200, 400, 403, 408, 500, 502, 503, and 504 (e.g. `400`)
* `haproxy_frontend.{n}.errorfile.{n}.file`: [required]: A file containing the full HTTP response (e.g `/etc/haproxy/errors/400.http`)
* `haproxy_frontend.{n}.raw_options`: [default: `[]`]: Additional arbitrary lines to insert in the section

* `haproxy_backend`: [default: `[]`]: Back-end declarations
* `haproxy_backend.{n}.name`: [required]: The name of the section (e.g. `webservers`)
Expand Down Expand Up @@ -360,6 +364,7 @@ Set up (the latest version of) [HAProxy](http://www.haproxy.org/) in Ubuntu syst
* `haproxy_backend.{n}.errorfile.{n}.code`: [required]: The HTTP status code. Currently, HAProxy is capable of generating codes 200, 400, 403, 408, 500, 502, 503, and 504 (e.g. `400`)
* `haproxy_backend.{n}.errorfile.{n}.file`: [required]: A file containing the full HTTP response (e.g `/etc/haproxy/errors/400.http`)
* `haproxy_backend.{n}.default_server_params`: [optional]: Default server params applied for each server for this particular backend entry.
* `haproxy_backend.{n}.raw_options`: [default: `[]`]: Additional arbitrary lines to insert in the section

* `haproxy_userlists`: [default: `[]`]: Userlist declarations
* `haproxy_userlists.{n}.name`: [required]: The name of the userlist
Expand Down
3 changes: 3 additions & 0 deletions templates/etc/haproxy/backend.cfg.j2
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,7 @@ backend {{ backend.name }}
errorfile {{ errorfile.code }} {{ errorfile.file }}
{% endfor %}

{% for line in backend.raw_options | default([]) %}
{{ line }}
{% endfor %}
{% endfor %}
4 changes: 4 additions & 0 deletions templates/etc/haproxy/defaults.cfg.j2
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,7 @@
{% if haproxy_default_server_params | default([]) %}
default-server {% for param in haproxy_default_server_params | default([]) %} {{ param }}{% endfor %}
{% endif %}

{% for line in haproxy_default_raw_options | default([]) %}
{{ line }}
{% endfor %}
3 changes: 3 additions & 0 deletions templates/etc/haproxy/frontend.cfg.j2
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,7 @@ frontend {{ frontend.name }}
errorfile {{ errorfile.code }} {{ errorfile.file }}
{% endfor %}

{% for line in frontend.raw_options | default([]) %}
{{ line }}
{% endfor %}
{% endfor %}
4 changes: 4 additions & 0 deletions templates/etc/haproxy/global.cfg.j2
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,7 @@ peers {{ peers.name }}
peer {{ peer.name }} {{ peer.listen }}
{% endfor %}
{% endfor %}

{% for line in haproxy_global_raw_options | default([]) %}
{{ line }}
{% endfor %}
3 changes: 3 additions & 0 deletions templates/etc/haproxy/listen.cfg.j2
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,7 @@ listen {{ listen.name }}
errorfile {{ errorfile.code }} {{ errorfile.file }}
{% endfor %}

{% for line in listen.raw_options | default([]) %}
{{ line }}
{% endfor %}
{% endfor %}
13 changes: 13 additions & 0 deletions tests/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@
roles:
- ../../
vars:
# global parameters
haproxy_global_raw_options:
- cpu-map 1/all 0-3
- server-state-file /tmp/haproxy.state

# default section
haproxy_default_raw_options:
- load-server-state-from-file global

# front-end section
haproxy_frontend:
- name: http
Expand All @@ -16,6 +25,8 @@
reqrep:
- search: "^Host:\\ (.*)"
string: "Host:\\ foo.com"
raw_options:
- rspideny ^Content-type:\\.*/ms-word

# back-end section
haproxy_backend:
Expand All @@ -26,6 +37,8 @@
- forwardfor
- 'httpchk HEAD / HTTP/1.1\r\nHost:localhost'
server: []
raw_options:
- rspdeny ^Content-type:\\.*/ms-word

# user-lists section
haproxy_userlists:
Expand Down

0 comments on commit b5947b7

Please sign in to comment.