diff --git a/README.md b/README.md index 93b8462..f952b50 100644 --- a/README.md +++ b/README.md @@ -400,7 +400,9 @@ Set up (the latest version of) [HAProxy](http://www.haproxy.org/) in Ubuntu syst * `haproxy_backend.{n}.server_dynamic.{n}.param`: [optional]: A list of parameters to apply on each backend server. * `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. * `haproxy_backend.{n}.retries`: [optional]: Number of retries to perform on a server after a connection failure - +* `haproxy_backend.{n}.email_alert`: [default: `[]`]: Specify email alerts option +* `haproxy_backend.{n}.email_alert.{n}.code`: [required]: Email alert key can be : mailers, from, to or level +* `haproxy_backend.{n}.email_alert.{n}.value`: [required]: Email alert key value * `haproxy_backend.{n}.errorfile`: [optional]: Errorfile declarations * `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 * `haproxy_program.{n}.option`: [default: `[]`]: Options to enable * `haproxy_program.{n}.no_option`: [default: `[]`]: Options to inverse/disable +* `haproxy_mailers`: [default: `[]`]: Mailers declarations +* `haproxy_mailers.{n}.name`: [required]: The name of the mailers group +* `haproxy_mailers.{n}.servers`: [default: `[]`]: SMTP servers declarations +* `haproxy_mailers.{n}.servers.{n}.name`: [required]: SMTP server name +* `haproxy_mailers.{n}.servers.{n}.host`: [required]: SMTP server host +* `haproxy_mailers.{n}.servers.{n}.port`: [default: `25`]: SMTP server name port + ## Dependencies None diff --git a/defaults/main.yml b/defaults/main.yml index 13167bb..e455c6e 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -73,6 +73,9 @@ haproxy_ssl_map: [] # listen section haproxy_listen: [] +# mailers section +haproxy_mailers: [] + # front-end section haproxy_frontend: [] diff --git a/templates/etc/haproxy/backend.cfg.j2 b/templates/etc/haproxy/backend.cfg.j2 index cf1c9a8..b3c965c 100644 --- a/templates/etc/haproxy/backend.cfg.j2 +++ b/templates/etc/haproxy/backend.cfg.j2 @@ -141,6 +141,9 @@ backend {{ backend.name }} {% for errorfile in backend.errorfile | default([]) %} errorfile {{ errorfile.code }} {{ errorfile.file }} {% endfor %} +{% for email_alert in backend.email_alert | default([]) %} + email-alert {{ email_alert.code }} {{ email_alert.value }} +{% endfor %} {% for line in backend.raw_options | default([]) %} {{ line }} {% endfor %} diff --git a/templates/etc/haproxy/haproxy.cfg.j2 b/templates/etc/haproxy/haproxy.cfg.j2 index 867083a..f01c0ee 100644 --- a/templates/etc/haproxy/haproxy.cfg.j2 +++ b/templates/etc/haproxy/haproxy.cfg.j2 @@ -16,6 +16,8 @@ defaults {% include 'cache.cfg.j2' %} +{% include 'mailers.cfg.j2' %} + {% include 'frontend.cfg.j2' %} {% include 'backend.cfg.j2' %} diff --git a/templates/etc/haproxy/mailers.cfg.j2 b/templates/etc/haproxy/mailers.cfg.j2 new file mode 100644 index 0000000..7df49bd --- /dev/null +++ b/templates/etc/haproxy/mailers.cfg.j2 @@ -0,0 +1,6 @@ +{% for mailer in haproxy_mailers | default([]) %} +mailers {{ mailer.name }} +{% for server in mailer.servers | default([]) %} + mailer {{ server.name }} {{ server.host }}:{{ server.port | default(25) }} +{% endfor %} +{% endfor %} \ No newline at end of file