Skip to content

Commit 59f8739

Browse files
committed
Add support for mailers and email-alert config
1 parent 5cf7490 commit 59f8739

File tree

5 files changed

+24
-1
lines changed

5 files changed

+24
-1
lines changed

README.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,9 @@ Set up (the latest version of) [HAProxy](http://www.haproxy.org/) in Ubuntu syst
400400
* `haproxy_backend.{n}.server_dynamic.{n}.param`: [optional]: A list of parameters to apply on each backend server.
401401
* `haproxy_backend.{n}.retry_on`: [optional, default `[]`]: Specify when to attempt to automatically retry a failed request. Provide a list of keywords or HTTP status codes, each representing a type of failure event on which an attempt to retry the request is desired. For details, see HAProxy documentation.
402402
* `haproxy_backend.{n}.retries`: [optional]: Number of retries to perform on a server after a connection failure
403-
403+
* `haproxy_backend.{n}.email_alert`: [default: `[]`]: Specify email alerts option
404+
* `haproxy_backend.{n}.email_alert.{n}.code`: [required]: Email alert key can be : mailers, from, to or level
405+
* `haproxy_backend.{n}.email_alert.{n}.value`: [required]: Email alert key value
404406

405407
* `haproxy_backend.{n}.errorfile`: [optional]: Errorfile declarations
406408
* `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`)
@@ -461,6 +463,13 @@ Set up (the latest version of) [HAProxy](http://www.haproxy.org/) in Ubuntu syst
461463
* `haproxy_program.{n}.option`: [default: `[]`]: Options to enable
462464
* `haproxy_program.{n}.no_option`: [default: `[]`]: Options to inverse/disable
463465

466+
* `haproxy_mailers`: [default: `[]`]: Mailers declarations
467+
* `haproxy_mailers.{n}.name`: [required]: The name of the mailers group
468+
* `haproxy_mailers.{n}.servers`: [default: `[]`]: SMTP servers declarations
469+
* `haproxy_mailers.{n}.servers.{n}.name`: [required]: SMTP server name
470+
* `haproxy_mailers.{n}.servers.{n}.host`: [required]: SMTP server host
471+
* `haproxy_mailers.{n}.servers.{n}.port`: [default: `25`]: SMTP server name port
472+
464473
## Dependencies
465474

466475
None

defaults/main.yml

+3
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ haproxy_ssl_map: []
7373
# listen section
7474
haproxy_listen: []
7575

76+
# mailers section
77+
haproxy_mailers: []
78+
7679
# front-end section
7780
haproxy_frontend: []
7881

templates/etc/haproxy/backend.cfg.j2

+3
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ backend {{ backend.name }}
141141
{% for errorfile in backend.errorfile | default([]) %}
142142
errorfile {{ errorfile.code }} {{ errorfile.file }}
143143
{% endfor %}
144+
{% for email_alert in backend.email_alert | default([]) %}
145+
email-alert {{ email_alert.code }} {{ email_alert.value }}
146+
{% endfor %}
144147
{% for line in backend.raw_options | default([]) %}
145148
{{ line }}
146149
{% endfor %}

templates/etc/haproxy/haproxy.cfg.j2

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ defaults
1616

1717
{% include 'cache.cfg.j2' %}
1818

19+
{% include 'mailers.cfg.j2' %}
20+
1921
{% include 'frontend.cfg.j2' %}
2022

2123
{% include 'backend.cfg.j2' %}

templates/etc/haproxy/mailers.cfg.j2

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{% for mailer in haproxy_mailers | default([]) %}
2+
mailers {{ mailer.name }}
3+
{% for server in mailer.servers | default([]) %}
4+
mailer {{ server.name }} {{ server.host }}:{{ server.port | default(25) }}
5+
{% endfor %}
6+
{% endfor %}

0 commit comments

Comments
 (0)