Use SMTP/Mailgun for backup notifications

This commit is contained in:
Basti 2021-11-30 13:37:51 -06:00
parent 3d1937823a
commit e63cda3317
Signed by untrusted user: basti
GPG Key ID: 9F88009D31D99C72
2 changed files with 14 additions and 2 deletions

View File

@ -32,6 +32,8 @@ gem_package 'backup' do
version '5.0.0.beta.2'
end
smtp_credentials = Chef::EncryptedDataBagItem.load('credentials', 'smtp')
backup_data = Chef::EncryptedDataBagItem.load('credentials', 'backup')
backup_dir = node["backup"]["dir"]
directory backup_dir
@ -46,8 +48,12 @@ template "#{backup_dir}/config.rb" do
s3_secret_access_key: backup_data["s3_secret_access_key"],
s3_region: backup_data["s3_region"],
encryption_password: backup_data["encryption_password"],
mail_from: "backups@kosmos.org",
mail_to: "ops@5apps.com",
mail_from: "backups@kosmos.org"
mail_address: 'smtp.mailgun.org',
mail_domain: 'kosmos.org',
mail_user_name: smtp_credentials["user_name"],
mail_password: smtp_credentials["password"]
end
template "#{backup_dir}/models/default.rb" do

View File

@ -22,7 +22,13 @@ end
Notifier::Mail.defaults do |mail|
mail.from = "<%= node.name %> <<%= @mail_from %>>"
mail.to = "<%= @mail_to %>"
mail.delivery_method = :sendmail
mail.address = "<%= @mail_address %>"
mail.domain = "<%= @mail_domain %>"
mail.user_name = "<%= @mail_user_name %>"
mail.password = "<%= @mail_password %>"
mail.port = <%= @mail_port || 587 %>
mail.authentication = "<%= @mail_authentication || 'plain' %>"
mail.encryption = <%= @mail_encryption || ':starttls' %>
end
<%- if node["backup"]["mongodb"] -%>