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,11 +21,13 @@ require 'chef/mash' | ||
| 21 | require 'chef/json_compat' | 21 | require 'chef/json_compat' |
| 22 | require 'chef/mixin/deep_merge' | 22 | require 'chef/mixin/deep_merge' |
| 23 | require 'securerandom' | 23 | require 'securerandom' |
| 24 | +require 'uri' | ||
| 24 | 25 | ||
| 25 | module Gitlab | 26 | module Gitlab |
| 26 | extend(Mixlib::Config) | 27 | extend(Mixlib::Config) |
| 27 | 28 | ||
| 28 | bootstrap Mash.new | 29 | bootstrap Mash.new |
| 30 | + user Mash.new | ||
| 29 | postgresql Mash.new | 31 | postgresql Mash.new |
| 30 | redis Mash.new | 32 | redis Mash.new |
| 31 | gitlab_rails Mash.new | 33 | gitlab_rails Mash.new |
| @@ -33,6 +35,7 @@ module Gitlab | @@ -33,6 +35,7 @@ module Gitlab | ||
| 33 | sidekiq Mash.new | 35 | sidekiq Mash.new |
| 34 | nginx Mash.new | 36 | nginx Mash.new |
| 35 | node nil | 37 | node nil |
| 38 | + external_url nil | ||
| 36 | 39 | ||
| 37 | class << self | 40 | class << self |
| 38 | 41 | ||
| @@ -72,10 +75,39 @@ module Gitlab | @@ -72,10 +75,39 @@ module Gitlab | ||
| 72 | end | 75 | end |
| 73 | end | 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 | def generate_hash | 106 | def generate_hash |
| 76 | results = { "gitlab" => {} } | 107 | results = { "gitlab" => {} } |
| 77 | [ | 108 | [ |
| 78 | "bootstrap", | 109 | "bootstrap", |
| 110 | + "user", | ||
| 79 | "redis", | 111 | "redis", |
| 80 | "gitlab_rails", | 112 | "gitlab_rails", |
| 81 | "unicorn", | 113 | "unicorn", |
| @@ -92,6 +124,7 @@ module Gitlab | @@ -92,6 +124,7 @@ module Gitlab | ||
| 92 | 124 | ||
| 93 | def generate_config(node_name) | 125 | def generate_config(node_name) |
| 94 | generate_secrets(node_name) | 126 | generate_secrets(node_name) |
| 127 | + parse_external_url | ||
| 95 | generate_hash | 128 | generate_hash |
| 96 | end | 129 | end |
| 97 | end | 130 | end |