Skip to content

Gitlab omnibus installation fails due to bad external_url

Summary

Installation fails b/c example config external_url is not a URI

Steps to reproduce

Follow the installation steps here: https://about.gitlab.com/installation/#ubuntu

apt-get install gitlab-ee fails with a chef error:

"GitLab external URL must include a schema and FQDN, e.g. http://gitlab.example.com/"

This appears to be a result of the following in the shipped config file:

##! For more details on configuring external_url see:
external_url 'GENERATED_EXTERNAL_URL'

Replacing that value with a valid URI and rerunning apt-get install gitlab-ee succeeds.

What is the current bug behavior?

apt-get install gitlab-ee fails with a chef error due to external_url not being a URI.

What is the expected correct behavior?

apt-get install gitlab-ee should succeed regardless of a bad configuration.

Relevant logs and/or screenshots

root@gitlab-i-0f0e6baaa77e2dabe:~# apt-get install gitlab-ee                                                                 [7146/9575]Reading package lists... Done                                                                                                           Building dependency tree                                                                                                                Reading state information... Done                                                                                                       gitlab-ee is already the newest version.                                                                                                0 upgraded, 0 newly installed, 0 to remove and 118 not upgraded.                                                                        1 not fully installed or removed.                                                                                                       After this operation, 0 B of additional disk space will be used.                                                                        Do you want to continue? [Y/n] y                                                                                                        Setting up gitlab-ee (10.0.3-ee.0) ...                                                                                                  Starting Chef Client, version 12.12.15                                                                                                  resolving cookbooks for run list: ["gitlab-ee"]                                                                                         Synchronizing Cookbooks:                                                                                                                  - package (0.1.0)                                                                                                                       - gitlab (0.0.1)                                                                                                                        - consul (0.0.0)                                                                                                                        - gitlab-ee (0.0.1)                                                                                                                     - runit (0.14.2)                                                                                                                        - registry (0.1.0)                                                                                                                      - repmgr (0.1.0)                                                                                                                      Installing Cookbook Gems:                                                                                                               Compiling Cookbooks...                                                                                                                                                                                                                                                          ================================================================================                                                        Recipe Compile Error in /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab-ee/recipes/default.rb                                     ================================================================================                                                                                                                                                                                                
RuntimeError
------------
GitLab external URL must include a schema and FQDN, e.g. http://gitlab.example.com/

Cookbook Trace:                                                                                                              [7115/9575]
---------------
  /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/libraries/gitlab_rails.rb:74:in `parse_external_url'
  /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/libraries/gitlab_rails.rb:25:in `parse_variables'
  /opt/gitlab/embedded/cookbooks/cache/cookbooks/package/libraries/helpers/settings_helper.rb:173:in `block in generate_config'
  /opt/gitlab/embedded/cookbooks/cache/cookbooks/package/libraries/helpers/settings_helper.rb:171:in `each'
  /opt/gitlab/embedded/cookbooks/cache/cookbooks/package/libraries/helpers/settings_helper.rb:171:in `generate_config'
  /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/config.rb:26:in `from_file'
  /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/default.rb:26:in `from_file'
  /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab-ee/recipes/default.rb:20:in `from_file'

Relevant File Content:
----------------------
/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/libraries/gitlab_rails.rb:

 67:
 68:      def parse_external_url
 69:        return unless Gitlab['external_url']
 70:
 71:        uri = URI(Gitlab['external_url'].to_s)
 72:
 73:        unless uri.host
 74>>         raise "GitLab external URL must include a schema and FQDN, e.g. http://gitlab.example.com/"
 75:        end
 76:        Gitlab['user']['git_user_email'] ||= "gitlab@#{uri.host}"
 77:        Gitlab['gitlab_rails']['gitlab_host'] = uri.host
 78:        Gitlab['gitlab_rails']['gitlab_email_from'] ||= "gitlab@#{uri.host}"
 79:
 80:        case uri.scheme
 81:        when "http"
 82:          Gitlab['gitlab_rails']['gitlab_https'] = false
 83:          Nginx.parse_proxy_headers('nginx', false)

Platform:
---------
x86_64-linux

Running handlers:
Running handlers complete
Chef Client failed. 0 resources updated in 03 seconds
dpkg: error processing package gitlab-ee (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 gitlab-ee
E: Sub-process /usr/bin/dpkg returned an error code (1)

Possible fixes

  • Ship a default config with a valid example URI
  • Infer a valid URI from the system hostname if one isn't set
  • Instead of raising an error and failing the chef run, WARN and continue in some fashion