From 6a5a3256c774f76a28487d5998e4672908565279 Mon Sep 17 00:00:00 2001 From: Valentino Cossar Date: Fri, 30 Mar 2018 22:46:26 +0200 Subject: [PATCH] Add support for sSMTP revaliases configuration (#956) --- CHANGELOG.md | 1 + roles/ssmtp/defaults/main.yml | 10 ++++++++++ roles/ssmtp/tasks/main.yml | 5 +++++ roles/ssmtp/templates/revaliases.j2 | 9 +++++++++ 4 files changed, 25 insertions(+) create mode 100644 roles/ssmtp/templates/revaliases.j2 diff --git a/CHANGELOG.md b/CHANGELOG.md index fdec3e424f..0310189faa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ ### HEAD +* Add support for sSMTP revaliases configuration ([#956](https://github.com/roots/trellis/pull/956)) * Add support for includes.d on all sites ([#966](https://github.com/roots/trellis/pull/966)) * Fix `--subdomains` flag in the Install WP task ([#968](https://github.com/roots/trellis/pull/968)) * Ensure Diffie-Hellman group is generated for Let's Encrypt ([#964](https://github.com/roots/trellis/pull/964)) diff --git a/roles/ssmtp/defaults/main.yml b/roles/ssmtp/defaults/main.yml index 2c684dbacf..c7310cf09e 100644 --- a/roles/ssmtp/defaults/main.yml +++ b/roles/ssmtp/defaults/main.yml @@ -3,3 +3,13 @@ ssmtp_auth_method: LOGIN ssmtp_from_override: 'Yes' ssmtp_start_tls: 'Yes' ssmtp_tls: 'Yes' +# ssmtp_revaliases: +# - user: root +# from: from@example.com +# smtp_server: "{{ mail_smtp_server }}" +# - user: "{{ admin_user }}" +# from: from@example.com +# smtp_server: "{{ mail_smtp_server }}" +# - user: "{{ web_user }}" +# from: from@example.com +# smtp_server: "{{ mail_smtp_server }}" diff --git a/roles/ssmtp/tasks/main.yml b/roles/ssmtp/tasks/main.yml index 910451621a..9d62055d4d 100644 --- a/roles/ssmtp/tasks/main.yml +++ b/roles/ssmtp/tasks/main.yml @@ -9,3 +9,8 @@ template: src: ssmtp.conf.j2 dest: /etc/ssmtp/ssmtp.conf + +- name: ssmtp revaliases configuration + template: + src: revaliases.j2 + dest: /etc/ssmtp/revaliases diff --git a/roles/ssmtp/templates/revaliases.j2 b/roles/ssmtp/templates/revaliases.j2 new file mode 100644 index 0000000000..2d66f62d04 --- /dev/null +++ b/roles/ssmtp/templates/revaliases.j2 @@ -0,0 +1,9 @@ +# {{ ansible_managed }} + +{% if ssmtp_revaliases is defined and ssmtp_revaliases is not none %} +{% for item in ssmtp_revaliases %} +{% if item.user is defined and item.user is not none and item.from is defined and item.from is not none and item.smtp_server is defined and item.smtp_server is not none %} +{{ item.user }}:{{ item.from }}:{{ item.smtp_server }} +{% endif %} +{% endfor %} +{% endif %}