From e1c7d63e823f84d507ecc26b3fb062fc9a840c23 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Sun, 16 Feb 2014 19:04:39 +0100 Subject: [PATCH] Specify the external_url in /etc/gitlab/gitlab.rb --- files/gitlab-cookbooks/gitlab/libraries/gitlab.rb | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+), 0 deletions(-) diff --git a/files/gitlab-cookbooks/gitlab/libraries/gitlab.rb b/files/gitlab-cookbooks/gitlab/libraries/gitlab.rb index fe8ea3f..b08c8fb 100644 --- a/files/gitlab-cookbooks/gitlab/libraries/gitlab.rb +++ b/files/gitlab-cookbooks/gitlab/libraries/gitlab.rb @@ -21,11 +21,13 @@ require 'chef/mash' require 'chef/json_compat' require 'chef/mixin/deep_merge' require 'securerandom' +require 'uri' module Gitlab extend(Mixlib::Config) bootstrap Mash.new + user Mash.new postgresql Mash.new redis Mash.new gitlab_rails Mash.new @@ -33,6 +35,7 @@ module Gitlab sidekiq Mash.new nginx Mash.new node nil + external_url nil class << self @@ -72,10 +75,39 @@ module Gitlab end end + def parse_external_url + return unless external_url + + uri = URI(external_url.to_s) + + unless uri.host + raise "External URL must include a FQDN" + end + Gitlab['user']['git_user_email'] ||= "gitlab@#{uri.host}" + Gitlab['gitlab_rails']['external_fqdn'] = uri.host + Gitlab['gitlab_rails']['notification_email'] ||= "gitlab@#{uri.host}" + + case uri.scheme + when "http" + Gitlab['gitlab_rails']['external_https'] = false + when "https" + Gitlab['gitlab_rails']['external_https'] = true + else + raise "Unsupported external URL scheme: #{uri.scheme}" + end + + unless ["", "/"].include?(uri.path) + raise "Unsupported external URL path: #{uri.path}" + end + + Gitlab['gitlab_rails']['external_port'] = uri.port + end + def generate_hash results = { "gitlab" => {} } [ "bootstrap", + "user", "redis", "gitlab_rails", "unicorn", @@ -92,6 +124,7 @@ module Gitlab def generate_config(node_name) generate_secrets(node_name) + parse_external_url generate_hash end end -- libgit2 0.21.2