From 1bae6828959c0277cd48941eb3507dffb5490190 Mon Sep 17 00:00:00 2001 From: Jochen P <12394156+jpylypiw@users.noreply.github.com> Date: Tue, 31 May 2022 09:34:42 +0200 Subject: [PATCH 1/4] Update Galera Monitoring Script to use TLS --- templates/etc/mysql/galeranotify.py.j2 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/templates/etc/mysql/galeranotify.py.j2 b/templates/etc/mysql/galeranotify.py.j2 index 3894af3..3f1027a 100644 --- a/templates/etc/mysql/galeranotify.py.j2 +++ b/templates/etc/mysql/galeranotify.py.j2 @@ -38,6 +38,9 @@ SMTP_PORT = {{ galera_notify_smtp_port }} # Set to True if you need SMTP over SSL SMTP_SSL = {{ galera_notify_smtp_ssl }} +# Set to True if you need SMTP over TLS +SMTP_TLS = {{ galera_notify_smtp_tls }} + # Set to True if you need to authenticate to your SMTP server SMTP_AUTH = {{ galera_notify_smtp_auth }} # Fill in authorization information here if True above @@ -90,7 +93,7 @@ def main(argv): message_obj.set_index(arg) try: send_notification(MAIL_FROM, MAIL_TO, 'Galera Notification: ' + THIS_SERVER, DATE, - str(message_obj), SMTP_SERVER, SMTP_PORT, SMTP_SSL, SMTP_AUTH, + str(message_obj), SMTP_SERVER, SMTP_PORT, SMTP_SSL, SMTP_TLS, SMTP_AUTH, SMTP_USERNAME, SMTP_PASSWORD) except Exception, e: print "Unable to send notification: %s" % e @@ -102,7 +105,7 @@ def main(argv): sys.exit(0) def send_notification(from_email, to_email, subject, date, message, smtp_server, - smtp_port, use_ssl, use_auth, smtp_user, smtp_pass): + smtp_port, use_ssl, use_tls, use_auth, smtp_user, smtp_pass): msg = MIMEText(message) msg['From'] = from_email @@ -116,6 +119,9 @@ def send_notification(from_email, to_email, subject, date, message, smtp_server, else: mailer = smtplib.SMTP(smtp_server, smtp_port) + if(use_tls): + mailer.starttls() + if(use_auth): mailer.login(smtp_user, smtp_pass) From a85819bc3781d96fd711533b203b0e47d21f8701 Mon Sep 17 00:00:00 2001 From: Jochen P <12394156+jpylypiw@users.noreply.github.com> Date: Tue, 31 May 2022 09:37:38 +0200 Subject: [PATCH 2/4] Update main.yml --- defaults/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/defaults/main.yml b/defaults/main.yml index e497ed4..e27e3c6 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -307,6 +307,8 @@ galera_notify_smtp_password: "" galera_notify_smtp_port: 25 # Set to True if you need SMTP over SSL galera_notify_smtp_ssl: False +# Set to True if you need SMTP over STARTTLS +galera_notify_smtp_starttls: False # Defines if cacti monitoring should be enabled for mysql - If used. May remove later. galera_enable_cacti_monitoring: false From 6e7385d01682129ca3cde3aeb752a70a7f1a4896 Mon Sep 17 00:00:00 2001 From: Jochen P <12394156+jpylypiw@users.noreply.github.com> Date: Tue, 31 May 2022 09:39:07 +0200 Subject: [PATCH 3/4] Update galeranotify.py.j2 --- templates/etc/mysql/galeranotify.py.j2 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/etc/mysql/galeranotify.py.j2 b/templates/etc/mysql/galeranotify.py.j2 index 3f1027a..bc8cf99 100644 --- a/templates/etc/mysql/galeranotify.py.j2 +++ b/templates/etc/mysql/galeranotify.py.j2 @@ -39,7 +39,7 @@ SMTP_PORT = {{ galera_notify_smtp_port }} SMTP_SSL = {{ galera_notify_smtp_ssl }} # Set to True if you need SMTP over TLS -SMTP_TLS = {{ galera_notify_smtp_tls }} +SMTP_STARTTLS = {{ galera_notify_smtp_starttls }} # Set to True if you need to authenticate to your SMTP server SMTP_AUTH = {{ galera_notify_smtp_auth }} @@ -93,7 +93,7 @@ def main(argv): message_obj.set_index(arg) try: send_notification(MAIL_FROM, MAIL_TO, 'Galera Notification: ' + THIS_SERVER, DATE, - str(message_obj), SMTP_SERVER, SMTP_PORT, SMTP_SSL, SMTP_TLS, SMTP_AUTH, + str(message_obj), SMTP_SERVER, SMTP_PORT, SMTP_SSL, SMTP_STARTTLS, SMTP_AUTH, SMTP_USERNAME, SMTP_PASSWORD) except Exception, e: print "Unable to send notification: %s" % e @@ -105,7 +105,7 @@ def main(argv): sys.exit(0) def send_notification(from_email, to_email, subject, date, message, smtp_server, - smtp_port, use_ssl, use_tls, use_auth, smtp_user, smtp_pass): + smtp_port, use_ssl, use_starttls, use_auth, smtp_user, smtp_pass): msg = MIMEText(message) msg['From'] = from_email @@ -119,7 +119,7 @@ def send_notification(from_email, to_email, subject, date, message, smtp_server, else: mailer = smtplib.SMTP(smtp_server, smtp_port) - if(use_tls): + if(use_starttls): mailer.starttls() if(use_auth): From b48a408be63917063e3672d6a4e415e214599a5f Mon Sep 17 00:00:00 2001 From: Jochen P <12394156+jpylypiw@users.noreply.github.com> Date: Tue, 31 May 2022 13:08:35 +0200 Subject: [PATCH 4/4] remove whitespances --- templates/etc/mysql/galeranotify.py.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/etc/mysql/galeranotify.py.j2 b/templates/etc/mysql/galeranotify.py.j2 index bc8cf99..02886bd 100644 --- a/templates/etc/mysql/galeranotify.py.j2 +++ b/templates/etc/mysql/galeranotify.py.j2 @@ -121,7 +121,7 @@ def send_notification(from_email, to_email, subject, date, message, smtp_server, if(use_starttls): mailer.starttls() - + if(use_auth): mailer.login(smtp_user, smtp_pass)