Commit e1c7d63e823f84d507ecc26b3fb062fc9a840c23
1 parent
d4a71c0d
Exists in
master
and in
17 other branches
Specify the external_url in /etc/gitlab/gitlab.rb
Showing
1 changed file
with
33 additions
and
0 deletions
Show diff stats
files/gitlab-cookbooks/gitlab/libraries/gitlab.rb
... | ... | @@ -21,11 +21,13 @@ require 'chef/mash' |
21 | 21 | require 'chef/json_compat' |
22 | 22 | require 'chef/mixin/deep_merge' |
23 | 23 | require 'securerandom' |
24 | +require 'uri' | |
24 | 25 | |
25 | 26 | module Gitlab |
26 | 27 | extend(Mixlib::Config) |
27 | 28 | |
28 | 29 | bootstrap Mash.new |
30 | + user Mash.new | |
29 | 31 | postgresql Mash.new |
30 | 32 | redis Mash.new |
31 | 33 | gitlab_rails Mash.new |
... | ... | @@ -33,6 +35,7 @@ module Gitlab |
33 | 35 | sidekiq Mash.new |
34 | 36 | nginx Mash.new |
35 | 37 | node nil |
38 | + external_url nil | |
36 | 39 | |
37 | 40 | class << self |
38 | 41 | |
... | ... | @@ -72,10 +75,39 @@ module Gitlab |
72 | 75 | end |
73 | 76 | end |
74 | 77 | |
78 | + def parse_external_url | |
79 | + return unless external_url | |
80 | + | |
81 | + uri = URI(external_url.to_s) | |
82 | + | |
83 | + unless uri.host | |
84 | + raise "External URL must include a FQDN" | |
85 | + end | |
86 | + Gitlab['user']['git_user_email'] ||= "gitlab@#{uri.host}" | |
87 | + Gitlab['gitlab_rails']['external_fqdn'] = uri.host | |
88 | + Gitlab['gitlab_rails']['notification_email'] ||= "gitlab@#{uri.host}" | |
89 | + | |
90 | + case uri.scheme | |
91 | + when "http" | |
92 | + Gitlab['gitlab_rails']['external_https'] = false | |
93 | + when "https" | |
94 | + Gitlab['gitlab_rails']['external_https'] = true | |
95 | + else | |
96 | + raise "Unsupported external URL scheme: #{uri.scheme}" | |
97 | + end | |
98 | + | |
99 | + unless ["", "/"].include?(uri.path) | |
100 | + raise "Unsupported external URL path: #{uri.path}" | |
101 | + end | |
102 | + | |
103 | + Gitlab['gitlab_rails']['external_port'] = uri.port | |
104 | + end | |
105 | + | |
75 | 106 | def generate_hash |
76 | 107 | results = { "gitlab" => {} } |
77 | 108 | [ |
78 | 109 | "bootstrap", |
110 | + "user", | |
79 | 111 | "redis", |
80 | 112 | "gitlab_rails", |
81 | 113 | "unicorn", |
... | ... | @@ -92,6 +124,7 @@ module Gitlab |
92 | 124 | |
93 | 125 | def generate_config(node_name) |
94 | 126 | generate_secrets(node_name) |
127 | + parse_external_url | |
95 | 128 | generate_hash |
96 | 129 | end |
97 | 130 | end | ... | ... |