Commit c64f7ece authored by Kirill Smelkov's avatar Kirill Smelkov

gitlab/smtp_settings.rb: Convert/integrate to slapos

Convert to slapos SMTP settings for gitlab:

    - convert to jinja2
    - remove support for gitlab CI (we do not support it (yet ?))
    - add handling of `smtp_enable` parameter directly to that file
      ( omnibus handles this parameter externally and just removes
        smtp_settings.rb if it is true )

NOTE smtp_settings.rb contains SMTP password, so it is mode is set to 0600.

/cc @kazuhiko, @jerome
parent a44f5a43
...@@ -17,6 +17,17 @@ configuration.db_pool = 10 ...@@ -17,6 +17,17 @@ configuration.db_pool = 10
configuration.rate_limit_requests_per_period = 10 configuration.rate_limit_requests_per_period = 10
configuration.rate_limit_period = 60 configuration.rate_limit_period = 60
configuration.smtp_enable = true
configuration.smtp_address = smtp.server
configuration.smtp_port = 465
configuration.smtp_user_name = smtp user
configuration.smtp_password = smtp password
configuration.smtp_domain = lab.example.com
configuration.smtp_authentication = login
configuration.smtp_enable_starttls_auto = true
# none | peer | client_once | fail_if_no_peer_cert -> see gitlab-omnibus links at top
configuration.smtp_openssl_verify_mode = peer
# unicorn advanced # unicorn advanced
configuration.unicorn_worker_memory_limit_min = 200*(1024**2) configuration.unicorn_worker_memory_limit_min = 200*(1024**2)
......
...@@ -172,6 +172,8 @@ context-extra = ...@@ -172,6 +172,8 @@ context-extra =
[smtp_settings.rb] [smtp_settings.rb]
<= gitlab-etc-template <= gitlab-etc-template
template= {{ smtp_settings_rb_in }} template= {{ smtp_settings_rb_in }}
# contains smtp password
mode = 0600
[unicorn.rb] [unicorn.rb]
<= gitlab-etc-template <= gitlab-etc-template
......
...@@ -4,17 +4,26 @@ ...@@ -4,17 +4,26 @@
# https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/files/gitlab-cookbooks/gitlab/templates/default/smtp_settings.rb.erb # https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/files/gitlab-cookbooks/gitlab/templates/default/smtp_settings.rb.erb
# (last updated for omnibus-gitlab 8.2.3+ce.0-0-g8eda093) # (last updated for omnibus-gitlab 8.2.3+ce.0-0-g8eda093)
<% rails_app = @app == 'gitlab' ? 'Gitlab' : 'GitlabCi' %> {% from 'macrolib.cfg.in' import cfg, cfg_bool with context %}
<% container = @app == 'gitlab' ? 'gitlab-rails' : 'gitlab-ci' %>
{% if cfg_bool('smtp_enable') %}
if Rails.env.production? if Rails.env.production?
<%= rails_app %>::Application.config.action_mailer.delivery_method = :smtp Gitlab::Application.config.action_mailer.delivery_method = :smtp
ActionMailer::Base.smtp_settings = { ActionMailer::Base.smtp_settings = {
authentication: <%= @smtp_authentication.to_s.to_sym.inspect %>, address: "{{ cfg('smtp_address') }}",
<% %w{ address port user_name password domain enable_starttls_auto tls openssl_verify_mode ca_path ca_file }.each do |key| %> port: {{ cfg('smtp_port') }},
<% value = node['gitlab'][container]["smtp_#{key}"] %> user_name: "{{ cfg('smtp_user_name') }}",
<%= "#{key}: #{value.inspect}," unless value.nil? %> password: "{{ cfg('smtp_password') }}",
<% end %> domain: "{{ cfg('smtp_domain') }}",
authentication: :{{ cfg('smtp_authentication') }},
enable_starttls_auto: {{ cfg('smtp_enable_starttls_auto') }},
openssl_verify_mode: '{{ cfg("smtp_openssl_verify_mode") }}'
# ca_path:
# ca_file:
} }
end end
{% else %}
# SMTP disabled in instance configuration (see `smtp_enable` parameter).
# Mail sending, if enabled (see `email_enabled`), will be done via sendmail.
{% endif %}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment