diff --git a/site-cookbooks/backup/recipes/default.rb b/site-cookbooks/backup/recipes/default.rb index a0aa1f7..564bcaf 100644 --- a/site-cookbooks/backup/recipes/default.rb +++ b/site-cookbooks/backup/recipes/default.rb @@ -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 diff --git a/site-cookbooks/backup/templates/default/config.rb.erb b/site-cookbooks/backup/templates/default/config.rb.erb index 1123f80..963a338 100644 --- a/site-cookbooks/backup/templates/default/config.rb.erb +++ b/site-cookbooks/backup/templates/default/config.rb.erb @@ -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"] -%>