Gitlab Config

The Gitlab config gem can be used in /etc/gitlab/gitlab.rb to provide dynamic configuration options for Gitlab.

Installation

gem install gitlab_config

Example Use

Local Configuration

If you have a number of configuration files locally they can be loaded based on an environment variable.

# /opt/test_config.yml
gitlab_rails:
  db_host: 'database.mygitlab.com'
  db_username: 'gitlab'
  db_password: 'apassword'

Within your /etc/gitlab/gitlab.yml this could be use as follows:

require 'gitlab_config'

options = {
  source: :local,
  file: "/opt/#{ENV['avar']}_config.yml"
}

GitlabConfig.load_configuration(options) do |config|
  config.fetch('gitlab_rails').each { |k, v| gitlab_rails[k] = v }
  postgresql['enable'] = config.fetch('gitlab_rails').has_key? 'db_host'
end

Here the options hash lists the source of the config as the local filesystem and the file key gives the path of the file using an environment variable. The load configuration block then takes the loaded configuration and applies to the gitlab_rails configuration object. You can also set other values like disabling the local database.