Skip to content

Commit

Permalink
Merge pull request #147 from saif-88/mailers
Browse files Browse the repository at this point in the history
Add support for mailers and email-alert config
  • Loading branch information
tersmitten authored Sep 24, 2023
2 parents 5cf7490 + 59f8739 commit 0f43098
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 1 deletion.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ haproxy_ssl_map: []
# listen section
haproxy_listen: []

# mailers section
haproxy_mailers: []

# front-end section
haproxy_frontend: []

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 @@ -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 %}
Expand Down
2 changes: 2 additions & 0 deletions templates/etc/haproxy/haproxy.cfg.j2
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ defaults

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

{% include 'mailers.cfg.j2' %}

{% include 'frontend.cfg.j2' %}

{% include 'backend.cfg.j2' %}
6 changes: 6 additions & 0 deletions templates/etc/haproxy/mailers.cfg.j2
Original file line number Diff line number Diff line change
@@ -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 %}

0 comments on commit 0f43098

Please sign in to comment.