From ac74661b7f4b07b5f369ca9a1637decef4263310 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Tue, 11 Feb 2014 15:05:05 +0100 Subject: [PATCH] Rename gitlab.core to gitlab.rails --- config/projects/gitlab.rb | 2 +- config/software/gitlab-core.rb | 76 ---------------------------------------------------------------------------- config/software/gitlab-rails.rb | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ config/templates/gitlab-core/bundle_exec_wrapper.erb | 13 ------------- config/templates/gitlab-rails/bundle_exec_wrapper.erb | 13 +++++++++++++ files/gitlab-cookbooks/gitlab/attributes/default.rb | 38 +++++++++++++++++++------------------- files/gitlab-cookbooks/gitlab/libraries/gitlab.rb | 10 +++++----- files/gitlab-cookbooks/gitlab/recipes/database_migrations.rb | 2 +- files/gitlab-cookbooks/gitlab/recipes/default.rb | 2 +- files/gitlab-cookbooks/gitlab/recipes/gitlab-core.rb | 100 ---------------------------------------------------------------------------------------------------- files/gitlab-cookbooks/gitlab/recipes/gitlab-rails.rb | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ files/gitlab-cookbooks/gitlab/recipes/gitlab-shell.rb | 4 ++-- files/gitlab-cookbooks/gitlab/recipes/unicorn.rb | 10 +++++----- files/gitlab-cookbooks/gitlab/templates/default/gitlab.yml.erb | 14 +++++++------- files/gitlab-cookbooks/gitlab/templates/default/rack_attack.rb.erb | 2 +- files/gitlab-cookbooks/gitlab/templates/default/secret_token.erb | 2 +- files/gitlab-cookbooks/gitlab/templates/default/sv-unicorn-run.erb | 4 ++-- 17 files changed, 234 insertions(+), 234 deletions(-) delete mode 100644 config/software/gitlab-core.rb create mode 100644 config/software/gitlab-rails.rb delete mode 100644 config/templates/gitlab-core/bundle_exec_wrapper.erb create mode 100644 config/templates/gitlab-rails/bundle_exec_wrapper.erb delete mode 100644 files/gitlab-cookbooks/gitlab/recipes/gitlab-core.rb create mode 100644 files/gitlab-cookbooks/gitlab/recipes/gitlab-rails.rb diff --git a/config/projects/gitlab.rb b/config/projects/gitlab.rb index e0eb06b..6239c2d 100644 --- a/config/projects/gitlab.rb +++ b/config/projects/gitlab.rb @@ -32,7 +32,7 @@ dependency "git" dependency "postgresql" dependency "redis" dependency "gitlab-shell" -dependency "gitlab-core" +dependency "gitlab-rails" dependency "chef-gem" dependency "gitlab-ctl" dependency "gitlab-cookbooks" diff --git a/config/software/gitlab-core.rb b/config/software/gitlab-core.rb deleted file mode 100644 index bd9dff0..0000000 --- a/config/software/gitlab-core.rb +++ /dev/null @@ -1,76 +0,0 @@ -# -# Copyright:: Copyright (c) 2012 Opscode, Inc. -# Copyright:: Copyright (c) 2014 GitLab.com -# License:: Apache License, Version 2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -name "gitlab-core" -version "master" - -dependency "ruby" -dependency "bundler" -dependency "libxml2" -dependency "libxslt" -dependency "curl" -dependency "rsync" -dependency "libicu" -dependency "postgresql" - -source :git => "https://gitlab.com/gitlab-org/gitlab-ce.git" - -build do - # GitLab assumes it can extract the Git revision of the currently version - # from the Git repo the code lives in at boot. Because of our rsync later on, - # this assumption does not hold. The sed command below patches the GitLab - # source code to include the Git revision of the code included in the omnibus - # build. - command "sed -i \"s/.*REVISION.*/REVISION = '$(git log --pretty=format:'%h' -n 1)'/\" config/initializers/2_app.rb" - - bundle "install --without mysql development test --path=#{install_dir}/embedded/service/gem" - - # In order to precompile the assets, we need to get to a state where rake can - # load the Rails environment. - command "cp config/gitlab.yml.example config/gitlab.yml" - command "cp config/database.yml.postgresql config/database.yml" - # There is a bug in the acts-as-taggable-on gem that makes - # rake assets:precompile check for a database connection. We do not have a - # database at this point so that is a problem. This bug is fixed in - # acts-as-taggable-on 3.0.0 by - # https://github.com/mbleigh/acts-as-taggable-on/commit/ad02dc9bb24ec8e1e79e7e35e2d4bb5910a66d8e - patch = "#{Omnibus.project_root}/config/patches/acts-as-taggable-on-ad02dc9bb24ec8e1e79e7e35e2d4bb5910a66d8e.diff" - # To make this idempotent, we apply the patch (in case this is a first run) or - # we revert and re-apply the patch (if this is a second or later run). - command "git apply #{patch} || (git apply -R #{patch} && git apply #{patch})", - :cwd => "#{install_dir}/embedded/service/gem/ruby/1.9.1/gems/acts-as-taggable-on-2.4.1" - rake "assets:precompile", :env => {"RAILS_ENV" => "production"} - # Tear down now that the assets:precompile is done. - command "rm config/gitlab.yml config/database.yml" - - command "mkdir -p #{install_dir}/embedded/service/gitlab-core" - command "rm -rf log tmp public/uploads" - command "#{install_dir}/embedded/bin/rsync -a --delete --exclude=.git/*** --exclude=.gitignore ./ #{install_dir}/embedded/service/gitlab-core/" - - # Create a wrapper for the rake tasks of the Rails app - erb :dest => "#{install_dir}/bin/gitlab-rake", - :source => "bundle_exec_wrapper.erb", - :mode => 0755, - :vars => {:command => 'rake "$@"', :install_dir => install_dir} - - # Create a wrapper for the rails command, useful for e.g. `rails console` - erb :dest => "#{install_dir}/bin/gitlab-rails", - :source => "bundle_exec_wrapper.erb", - :mode => 0755, - :vars => {:command => 'rails "$@"', :install_dir => install_dir} -end diff --git a/config/software/gitlab-rails.rb b/config/software/gitlab-rails.rb new file mode 100644 index 0000000..a958a3b --- /dev/null +++ b/config/software/gitlab-rails.rb @@ -0,0 +1,76 @@ +# +# Copyright:: Copyright (c) 2012 Opscode, Inc. +# Copyright:: Copyright (c) 2014 GitLab.com +# License:: Apache License, Version 2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +name "gitlab-rails" +version "master" + +dependency "ruby" +dependency "bundler" +dependency "libxml2" +dependency "libxslt" +dependency "curl" +dependency "rsync" +dependency "libicu" +dependency "postgresql" + +source :git => "https://gitlab.com/gitlab-org/gitlab-ce.git" + +build do + # GitLab assumes it can extract the Git revision of the currently version + # from the Git repo the code lives in at boot. Because of our rsync later on, + # this assumption does not hold. The sed command below patches the GitLab + # source code to include the Git revision of the code included in the omnibus + # build. + command "sed -i \"s/.*REVISION.*/REVISION = '$(git log --pretty=format:'%h' -n 1)'/\" config/initializers/2_app.rb" + + bundle "install --without mysql development test --path=#{install_dir}/embedded/service/gem" + + # In order to precompile the assets, we need to get to a state where rake can + # load the Rails environment. + command "cp config/gitlab.yml.example config/gitlab.yml" + command "cp config/database.yml.postgresql config/database.yml" + # There is a bug in the acts-as-taggable-on gem that makes + # rake assets:precompile check for a database connection. We do not have a + # database at this point so that is a problem. This bug is fixed in + # acts-as-taggable-on 3.0.0 by + # https://github.com/mbleigh/acts-as-taggable-on/commit/ad02dc9bb24ec8e1e79e7e35e2d4bb5910a66d8e + patch = "#{Omnibus.project_root}/config/patches/acts-as-taggable-on-ad02dc9bb24ec8e1e79e7e35e2d4bb5910a66d8e.diff" + # To make this idempotent, we apply the patch (in case this is a first run) or + # we revert and re-apply the patch (if this is a second or later run). + command "git apply #{patch} || (git apply -R #{patch} && git apply #{patch})", + :cwd => "#{install_dir}/embedded/service/gem/ruby/1.9.1/gems/acts-as-taggable-on-2.4.1" + rake "assets:precompile", :env => {"RAILS_ENV" => "production"} + # Tear down now that the assets:precompile is done. + command "rm config/gitlab.yml config/database.yml" + + command "mkdir -p #{install_dir}/embedded/service/gitlab-rails" + command "rm -rf log tmp public/uploads" + command "#{install_dir}/embedded/bin/rsync -a --delete --exclude=.git/*** --exclude=.gitignore ./ #{install_dir}/embedded/service/gitlab-rails/" + + # Create a wrapper for the rake tasks of the Rails app + erb :dest => "#{install_dir}/bin/gitlab-rake", + :source => "bundle_exec_wrapper.erb", + :mode => 0755, + :vars => {:command => 'rake "$@"', :install_dir => install_dir} + + # Create a wrapper for the rails command, useful for e.g. `rails console` + erb :dest => "#{install_dir}/bin/gitlab-rails", + :source => "bundle_exec_wrapper.erb", + :mode => 0755, + :vars => {:command => 'rails "$@"', :install_dir => install_dir} +end diff --git a/config/templates/gitlab-core/bundle_exec_wrapper.erb b/config/templates/gitlab-core/bundle_exec_wrapper.erb deleted file mode 100644 index 48c479f..0000000 --- a/config/templates/gitlab-core/bundle_exec_wrapper.erb +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -export PATH=<%= install_dir %>/bin:<%= install_dir %>/embedded/bin:$PATH - -# default to RAILS_ENV=production -if [[ -z $RAILS_ENV ]]; then - export RAILS_ENV=production -fi - -gitlab_user=$(ls -lLd <%= install_dir %>/embedded/service/gitlab-core/log | awk '{ print $3 }') - -cd <%= install_dir %>/embedded/service/gitlab-core -exec <%= install_dir %>/embedded/bin/chpst -u $gitlab_user -U $gitlab_user <%= install_dir %>/embedded/bin/bundle exec <%= command %> diff --git a/config/templates/gitlab-rails/bundle_exec_wrapper.erb b/config/templates/gitlab-rails/bundle_exec_wrapper.erb new file mode 100644 index 0000000..e7e500d --- /dev/null +++ b/config/templates/gitlab-rails/bundle_exec_wrapper.erb @@ -0,0 +1,13 @@ +#!/bin/bash + +export PATH=<%= install_dir %>/bin:<%= install_dir %>/embedded/bin:$PATH + +# default to RAILS_ENV=production +if [[ -z $RAILS_ENV ]]; then + export RAILS_ENV=production +fi + +gitlab_user=$(ls -lLd <%= install_dir %>/embedded/service/gitlab-rails/log | awk '{ print $3 }') + +cd <%= install_dir %>/embedded/service/gitlab-rails +exec <%= install_dir %>/embedded/bin/chpst -u $gitlab_user -U $gitlab_user <%= install_dir %>/embedded/bin/bundle exec <%= command %> diff --git a/files/gitlab-cookbooks/gitlab/attributes/default.rb b/files/gitlab-cookbooks/gitlab/attributes/default.rb index aaea86b..213b45a 100644 --- a/files/gitlab-cookbooks/gitlab/attributes/default.rb +++ b/files/gitlab-cookbooks/gitlab/attributes/default.rb @@ -39,24 +39,24 @@ default['gitlab']['user']['git_user_email'] = "gitlab@#{node['fqdn']}" #### # GitLab core #### -default['gitlab']['gitlab-core']['enable'] = true -default['gitlab']['gitlab-core']['ha'] = false -default['gitlab']['gitlab-core']['dir'] = "/var/opt/gitlab/gitlab-core" -default['gitlab']['gitlab-core']['log_directory'] = "/var/log/gitlab/gitlab-core" -default['gitlab']['gitlab-core']['environment'] = 'production' -default['gitlab']['gitlab-core']['umask'] = "0022" - -default['gitlab']['gitlab-core']['repositories_path'] = "/var/opt/gitlab/repositories" -default['gitlab']['gitlab-core']['satellites_path'] = "/var/opt/gitlab/gitlab-satellites" -default['gitlab']['gitlab-core']['internal_api_url'] = "http://localhost:8080" -default['gitlab']['gitlab-core']['external_fqdn'] = node['fqdn'] -default['gitlab']['gitlab-core']['external_port'] = 80 -default['gitlab']['gitlab-core']['external_https'] = false -default['gitlab']['gitlab-core']['notification_email'] = "gitlab@#{node['fqdn']}" -default['gitlab']['gitlab-core']['support_email'] = "support@example.com" -default['gitlab']['gitlab-core']['uploads_directory'] = "/var/opt/gitlab/uploads" -default['gitlab']['gitlab-core']['rate_limit_requests_per_period'] = 10 -default['gitlab']['gitlab-core']['rate_limit_period'] = 60 +default['gitlab']['gitlab-rails']['enable'] = true +default['gitlab']['gitlab-rails']['ha'] = false +default['gitlab']['gitlab-rails']['dir'] = "/var/opt/gitlab/gitlab-rails" +default['gitlab']['gitlab-rails']['log_directory'] = "/var/log/gitlab/gitlab-rails" +default['gitlab']['gitlab-rails']['environment'] = 'production' +default['gitlab']['gitlab-rails']['umask'] = "0022" + +default['gitlab']['gitlab-rails']['repositories_path'] = "/var/opt/gitlab/repositories" +default['gitlab']['gitlab-rails']['satellites_path'] = "/var/opt/gitlab/gitlab-satellites" +default['gitlab']['gitlab-rails']['internal_api_url'] = "http://localhost:8080" +default['gitlab']['gitlab-rails']['external_fqdn'] = node['fqdn'] +default['gitlab']['gitlab-rails']['external_port'] = 80 +default['gitlab']['gitlab-rails']['external_https'] = false +default['gitlab']['gitlab-rails']['notification_email'] = "gitlab@#{node['fqdn']}" +default['gitlab']['gitlab-rails']['support_email'] = "support@example.com" +default['gitlab']['gitlab-rails']['uploads_directory'] = "/var/opt/gitlab/uploads" +default['gitlab']['gitlab-rails']['rate_limit_requests_per_period'] = 10 +default['gitlab']['gitlab-rails']['rate_limit_period'] = 60 #### @@ -67,7 +67,7 @@ default['gitlab']['unicorn']['log_directory'] = "/var/log/gitlab/unicorn" default['gitlab']['unicorn']['worker_processes'] = 2 default['gitlab']['unicorn']['listen'] = '127.0.0.1' default['gitlab']['unicorn']['port'] = 8080 -default['gitlab']['unicorn']['socket'] = '/var/opt/gitlab/gitlab-core/tmp/sockets/gitlab.socket' +default['gitlab']['unicorn']['socket'] = '/var/opt/gitlab/gitlab-rails/tmp/sockets/gitlab.socket' default['gitlab']['unicorn']['tcp_nopush'] = true default['gitlab']['unicorn']['backlog_socket'] = 64 default['gitlab']['unicorn']['worker_timeout'] = 30 diff --git a/files/gitlab-cookbooks/gitlab/libraries/gitlab.rb b/files/gitlab-cookbooks/gitlab/libraries/gitlab.rb index ed13ff5..fe133b6 100644 --- a/files/gitlab-cookbooks/gitlab/libraries/gitlab.rb +++ b/files/gitlab-cookbooks/gitlab/libraries/gitlab.rb @@ -28,7 +28,7 @@ module Gitlab bootstrap Mash.new postgresql Mash.new redis Mash.new - gitlab_core Mash.new + gitlab_rails Mash.new unicorn Mash.new node nil @@ -51,7 +51,7 @@ module Gitlab end Gitlab['postgresql']['sql_password'] ||= generate_hex(50) - Gitlab['gitlab_core']['secret_token'] ||= generate_hex(64) + Gitlab['gitlab_rails']['secret_token'] ||= generate_hex(64) if File.directory?("/etc/gitlab") File.open("/etc/gitlab/gitlab-secrets.json", "w") do |f| @@ -60,8 +60,8 @@ module Gitlab 'postgresql' => { 'sql_password' => Gitlab['postgresql']['sql_password'], }, - 'gitlab_core' => { - 'secret_token' => Gitlab['gitlab_core']['secret_token'], + 'gitlab_rails' => { + 'secret_token' => Gitlab['gitlab_rails']['secret_token'], } }) ) @@ -75,7 +75,7 @@ module Gitlab [ "bootstrap", "redis", - "gitlab_core", + "gitlab_rails", "unicorn", "postgresql" ].each do |key| diff --git a/files/gitlab-cookbooks/gitlab/recipes/database_migrations.rb b/files/gitlab-cookbooks/gitlab/recipes/database_migrations.rb index 0dd9ab1..e6686e7 100644 --- a/files/gitlab-cookbooks/gitlab/recipes/database_migrations.rb +++ b/files/gitlab-cookbooks/gitlab/recipes/database_migrations.rb @@ -21,7 +21,7 @@ execute "initialize database" do end user_group = "#{node['gitlab']['user']['username']}:#{node['gitlab']['user']['group']}" -execute "chown #{user_group} /opt/gitlab/embedded/service/gitlab-core/db/schema.rb" +execute "chown #{user_group} /opt/gitlab/embedded/service/gitlab-rails/db/schema.rb" execute "migrate database" do command "/opt/gitlab/bin/gitlab-rake db:migrate" diff --git a/files/gitlab-cookbooks/gitlab/recipes/default.rb b/files/gitlab-cookbooks/gitlab/recipes/default.rb index c30c189..5945315 100644 --- a/files/gitlab-cookbooks/gitlab/recipes/default.rb +++ b/files/gitlab-cookbooks/gitlab/recipes/default.rb @@ -47,7 +47,7 @@ end include_recipe "gitlab::users" include_recipe "gitlab::gitlab-shell" -include_recipe "gitlab::gitlab-core" +include_recipe "gitlab::gitlab-rails" # Create a dummy unicorn service to receive notifications, in case the # gitlab::unicorn is not loaded below. diff --git a/files/gitlab-cookbooks/gitlab/recipes/gitlab-core.rb b/files/gitlab-cookbooks/gitlab/recipes/gitlab-core.rb deleted file mode 100644 index 2a9a1c4..0000000 --- a/files/gitlab-cookbooks/gitlab/recipes/gitlab-core.rb +++ /dev/null @@ -1,100 +0,0 @@ -# -# Copyright:: Copyright (c) 2012 Opscode, Inc. -# Copyright:: Copyright (c) 2014 GitLab.com -# License:: Apache License, Version 2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -gitlab_core_source_dir = "/opt/gitlab/embedded/service/gitlab-core" -gitlab_core_dir = node['gitlab']['gitlab-core']['dir'] -gitlab_core_etc_dir = File.join(gitlab_core_dir, "etc") -gitlab_core_working_dir = File.join(gitlab_core_dir, "working") -gitlab_core_tmp_dir = File.join(gitlab_core_dir, "tmp") -gitlab_core_public_uploads_dir = node['gitlab']['gitlab-core']['uploads_directory'] -gitlab_core_log_dir = node['gitlab']['gitlab-core']['log_directory'] - -[ - gitlab_core_dir, - gitlab_core_etc_dir, - gitlab_core_working_dir, - gitlab_core_tmp_dir, - gitlab_core_public_uploads_dir, - gitlab_core_log_dir -].each do |dir_name| - directory dir_name do - owner node['gitlab']['user']['username'] - mode '0700' - recursive true - end -end - -should_notify_unicorn = OmnibusHelper.should_notify?("unicorn") - -template_symlink File.join(gitlab_core_etc_dir, "secret") do - link_from File.join(gitlab_core_source_dir, ".secret") - source "secret_token.erb" - owner "root" - group "root" - mode "0644" - notifies :restart, 'service[unicorn]' if should_notify_unicorn -end - -template_symlink File.join(gitlab_core_etc_dir, "database.yml") do - link_from File.join(gitlab_core_source_dir, "config/database.yml") - source "database.yml.postgresql.erb" - owner "root" - group "root" - mode "0644" - variables(node['gitlab']['postgresql'].to_hash) - notifies :restart, 'service[unicorn]' if should_notify_unicorn -end - -template_symlink File.join(gitlab_core_etc_dir, "gitlab.yml") do - link_from File.join(gitlab_core_source_dir, "config/gitlab.yml") - source "gitlab.yml.erb" - owner "root" - group "root" - mode "0644" - variables(node['gitlab']['gitlab-core'].to_hash) - notifies :restart, 'service[unicorn]' if should_notify_unicorn -end - -template_symlink File.join(gitlab_core_etc_dir, "rack_attack.rb") do - link_from File.join(gitlab_core_source_dir, "config/initializers/rack_attack.rb") - source "rack_attack.rb.erb" - owner "root" - group "root" - mode "0644" - variables(node['gitlab']['gitlab-core'].to_hash) - notifies :restart, 'service[unicorn]' if should_notify_unicorn -end - -directory node['gitlab']['gitlab-core']['satellites_path'] do - owner node['gitlab']['user']['username'] - group node['gitlab']['user']['group'] - recursive true -end - -# replace empty directories in the Git repo with symlinks to /var/opt/gitlab -{ - "/opt/gitlab/embedded/service/gitlab-core/tmp" => gitlab_core_tmp_dir, - "/opt/gitlab/embedded/service/gitlab-core/public/uploads" => gitlab_core_public_uploads_dir, - "/opt/gitlab/embedded/service/gitlab-core/log" => gitlab_core_log_dir -}.each do |link_dir, target_dir| - link link_dir do - to target_dir - end -end - -execute "chown -R #{node['gitlab']['user']['username']} /opt/gitlab/embedded/service/gitlab-core/public" diff --git a/files/gitlab-cookbooks/gitlab/recipes/gitlab-rails.rb b/files/gitlab-cookbooks/gitlab/recipes/gitlab-rails.rb new file mode 100644 index 0000000..a6f0337 --- /dev/null +++ b/files/gitlab-cookbooks/gitlab/recipes/gitlab-rails.rb @@ -0,0 +1,100 @@ +# +# Copyright:: Copyright (c) 2012 Opscode, Inc. +# Copyright:: Copyright (c) 2014 GitLab.com +# License:: Apache License, Version 2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +gitlab_rails_source_dir = "/opt/gitlab/embedded/service/gitlab-rails" +gitlab_rails_dir = node['gitlab']['gitlab-rails']['dir'] +gitlab_rails_etc_dir = File.join(gitlab_rails_dir, "etc") +gitlab_rails_working_dir = File.join(gitlab_rails_dir, "working") +gitlab_rails_tmp_dir = File.join(gitlab_rails_dir, "tmp") +gitlab_rails_public_uploads_dir = node['gitlab']['gitlab-rails']['uploads_directory'] +gitlab_rails_log_dir = node['gitlab']['gitlab-rails']['log_directory'] + +[ + gitlab_rails_dir, + gitlab_rails_etc_dir, + gitlab_rails_working_dir, + gitlab_rails_tmp_dir, + gitlab_rails_public_uploads_dir, + gitlab_rails_log_dir +].each do |dir_name| + directory dir_name do + owner node['gitlab']['user']['username'] + mode '0700' + recursive true + end +end + +should_notify_unicorn = OmnibusHelper.should_notify?("unicorn") + +template_symlink File.join(gitlab_rails_etc_dir, "secret") do + link_from File.join(gitlab_rails_source_dir, ".secret") + source "secret_token.erb" + owner "root" + group "root" + mode "0644" + notifies :restart, 'service[unicorn]' if should_notify_unicorn +end + +template_symlink File.join(gitlab_rails_etc_dir, "database.yml") do + link_from File.join(gitlab_rails_source_dir, "config/database.yml") + source "database.yml.postgresql.erb" + owner "root" + group "root" + mode "0644" + variables(node['gitlab']['postgresql'].to_hash) + notifies :restart, 'service[unicorn]' if should_notify_unicorn +end + +template_symlink File.join(gitlab_rails_etc_dir, "gitlab.yml") do + link_from File.join(gitlab_rails_source_dir, "config/gitlab.yml") + source "gitlab.yml.erb" + owner "root" + group "root" + mode "0644" + variables(node['gitlab']['gitlab-rails'].to_hash) + notifies :restart, 'service[unicorn]' if should_notify_unicorn +end + +template_symlink File.join(gitlab_rails_etc_dir, "rack_attack.rb") do + link_from File.join(gitlab_rails_source_dir, "config/initializers/rack_attack.rb") + source "rack_attack.rb.erb" + owner "root" + group "root" + mode "0644" + variables(node['gitlab']['gitlab-rails'].to_hash) + notifies :restart, 'service[unicorn]' if should_notify_unicorn +end + +directory node['gitlab']['gitlab-rails']['satellites_path'] do + owner node['gitlab']['user']['username'] + group node['gitlab']['user']['group'] + recursive true +end + +# replace empty directories in the Git repo with symlinks to /var/opt/gitlab +{ + "/opt/gitlab/embedded/service/gitlab-rails/tmp" => gitlab_rails_tmp_dir, + "/opt/gitlab/embedded/service/gitlab-rails/public/uploads" => gitlab_rails_public_uploads_dir, + "/opt/gitlab/embedded/service/gitlab-rails/log" => gitlab_rails_log_dir +}.each do |link_dir, target_dir| + link link_dir do + to target_dir + end +end + +execute "chown -R #{node['gitlab']['user']['username']} /opt/gitlab/embedded/service/gitlab-rails/public" diff --git a/files/gitlab-cookbooks/gitlab/recipes/gitlab-shell.rb b/files/gitlab-cookbooks/gitlab/recipes/gitlab-shell.rb index 147492d..afac02a 100644 --- a/files/gitlab-cookbooks/gitlab/recipes/gitlab-shell.rb +++ b/files/gitlab-cookbooks/gitlab/recipes/gitlab-shell.rb @@ -20,7 +20,7 @@ git_user = node['gitlab']['user']['username'] git_group = node['gitlab']['user']['group'] gitlab_shell_dir = "/opt/gitlab/embedded/service/gitlab-shell" gitlab_shell_var_dir = "/var/opt/gitlab/gitlab-shell" -repositories_path = node['gitlab']['gitlab-core']['repositories_path'] +repositories_path = node['gitlab']['gitlab-rails']['repositories_path'] ssh_dir = File.join(node['gitlab']['user']['home'], ".ssh") log_directory = node['gitlab']['gitlab-shell']['log_directory'] @@ -54,7 +54,7 @@ template_symlink File.join(gitlab_shell_var_dir, "config.yml") do source "gitlab-shell-config.yml.erb" variables( :user => git_user, - :api_url => node['gitlab']['gitlab-core']['internal_api_url'], + :api_url => node['gitlab']['gitlab-rails']['internal_api_url'], :repositories_path => repositories_path, :authorized_keys => File.join(ssh_dir, "authorized_keys"), :redis_port => node['gitlab']['redis']['port'], diff --git a/files/gitlab-cookbooks/gitlab/recipes/unicorn.rb b/files/gitlab-cookbooks/gitlab/recipes/unicorn.rb index c805426..5f5b49f 100644 --- a/files/gitlab-cookbooks/gitlab/recipes/unicorn.rb +++ b/files/gitlab-cookbooks/gitlab/recipes/unicorn.rb @@ -16,9 +16,9 @@ # limitations under the License. # -gitlab_core_dir = node['gitlab']['gitlab-core']['dir'] -gitlab_core_etc_dir = File.join(gitlab_core_dir, "etc") -gitlab_core_working_dir = File.join(gitlab_core_dir, "working") +gitlab_rails_dir = node['gitlab']['gitlab-rails']['dir'] +gitlab_rails_etc_dir = File.join(gitlab_rails_dir, "etc") +gitlab_rails_working_dir = File.join(gitlab_rails_dir, "working") unicorn_listen_socket = node['gitlab']['unicorn']['socket'] unicorn_log_dir = node['gitlab']['unicorn']['log_directory'] @@ -38,7 +38,7 @@ end unicorn_listen_tcp = node['gitlab']['unicorn']['listen'] unicorn_listen_tcp << ":#{node['gitlab']['unicorn']['port']}" -unicorn_config File.join(gitlab_core_etc_dir, "unicorn.rb") do +unicorn_config File.join(gitlab_rails_etc_dir, "unicorn.rb") do listen( unicorn_listen_tcp => { :tcp_nopush => node['gitlab']['unicorn']['tcp_nopush'] @@ -48,7 +48,7 @@ unicorn_config File.join(gitlab_core_etc_dir, "unicorn.rb") do } ) worker_timeout node['gitlab']['unicorn']['worker_timeout'] - working_directory gitlab_core_working_dir + working_directory gitlab_rails_working_dir worker_processes node['gitlab']['unicorn']['worker_processes'] preload_app true owner "root" diff --git a/files/gitlab-cookbooks/gitlab/templates/default/gitlab.yml.erb b/files/gitlab-cookbooks/gitlab/templates/default/gitlab.yml.erb index 7e54dca..f88fd5a 100644 --- a/files/gitlab-cookbooks/gitlab/templates/default/gitlab.yml.erb +++ b/files/gitlab-cookbooks/gitlab/templates/default/gitlab.yml.erb @@ -15,9 +15,9 @@ production: &base ## GitLab settings gitlab: ## Web server settings (note: host is the FQDN, do not include http://) - host: <%= node['gitlab']['gitlab-core']['external_fqdn'] %> - port: <%= node['gitlab']['gitlab-core']['external_port'] %> - https: <%= node['gitlab']['gitlab-core']['external_https'] %> + host: <%= node['gitlab']['gitlab-rails']['external_fqdn'] %> + port: <%= node['gitlab']['gitlab-rails']['external_port'] %> + https: <%= node['gitlab']['gitlab-rails']['external_https'] %> # Uncomment and customize the last line to run in a non-root path # WARNING: We recommend creating a FQDN to host GitLab in a root path instead of this. @@ -35,10 +35,10 @@ production: &base ## Email settings # Email address used in the "From" field in mails sent by GitLab - email_from: <%= node['gitlab']['gitlab-core']['notification_email'] %> + email_from: <%= node['gitlab']['gitlab-rails']['notification_email'] %> # Email address of your support contact (default: same as email_from) - support_email: <%= node['gitlab']['gitlab-core']['support_email'] %> + support_email: <%= node['gitlab']['gitlab-rails']['support_email'] %> ## User settings default_projects_limit: 10 @@ -175,7 +175,7 @@ production: &base # GitLab Satellites satellites: # Relative paths are relative to Rails.root (default: tmp/repo_satellites/) - path: <%= node['gitlab']['gitlab-core']['satellites_path'] %> + path: <%= node['gitlab']['gitlab-rails']['satellites_path'] %> ## Backup settings backup: @@ -187,7 +187,7 @@ production: &base path: /opt/gitlab/embedded/service/gitlab-shell/ # REPOS_PATH MUST NOT BE A SYMLINK!!! - repos_path: <%= node['gitlab']['gitlab-core']['repositories_path'] %> + repos_path: <%= node['gitlab']['gitlab-rails']['repositories_path'] %> hooks_path: /opt/gitlab/embedded/service/gitlab-shell/hooks/ # Git over HTTP diff --git a/files/gitlab-cookbooks/gitlab/templates/default/rack_attack.rb.erb b/files/gitlab-cookbooks/gitlab/templates/default/rack_attack.rb.erb index 0a0f4c7..8b83945 100644 --- a/files/gitlab-cookbooks/gitlab/templates/default/rack_attack.rb.erb +++ b/files/gitlab-cookbooks/gitlab/templates/default/rack_attack.rb.erb @@ -12,7 +12,7 @@ paths_to_be_protected = [ ] unless Rails.env.test? - Rack::Attack.throttle('protected paths', limit: <%= node['gitlab']['gitlab-core']['rate_limit_requests_per_period'] %>, period: <%= node['gitlab']['gitlab-core']['rate_limit_period'] %>.seconds) do |req| + Rack::Attack.throttle('protected paths', limit: <%= node['gitlab']['gitlab-rails']['rate_limit_requests_per_period'] %>, period: <%= node['gitlab']['gitlab-rails']['rate_limit_period'] %>.seconds) do |req| req.ip if paths_to_be_protected.include?(req.path) && req.post? end end diff --git a/files/gitlab-cookbooks/gitlab/templates/default/secret_token.erb b/files/gitlab-cookbooks/gitlab/templates/default/secret_token.erb index 4251f75..9d66756 100644 --- a/files/gitlab-cookbooks/gitlab/templates/default/secret_token.erb +++ b/files/gitlab-cookbooks/gitlab/templates/default/secret_token.erb @@ -1 +1 @@ -<%= node['gitlab']['gitlab-core']['secret_token'] %> +<%= node['gitlab']['gitlab-rails']['secret_token'] %> diff --git a/files/gitlab-cookbooks/gitlab/templates/default/sv-unicorn-run.erb b/files/gitlab-cookbooks/gitlab/templates/default/sv-unicorn-run.erb index 161789a..1653a0d 100644 --- a/files/gitlab-cookbooks/gitlab/templates/default/sv-unicorn-run.erb +++ b/files/gitlab-cookbooks/gitlab/templates/default/sv-unicorn-run.erb @@ -1,6 +1,6 @@ #!/bin/sh -cd /opt/gitlab/embedded/service/gitlab-core +cd /opt/gitlab/embedded/service/gitlab-rails exec 2>&1 -exec chpst -P -U <%= node['gitlab']['user']['username'] %> -u <%= node['gitlab']['user']['username'] %> /usr/bin/env HOME="<%= node['gitlab']['gitlab-core']['dir'] %>" /opt/gitlab/embedded/bin/bundle exec unicorn -E <%= node['gitlab']['gitlab-core']['environment'] %> -c <%= File.join(node['gitlab']['gitlab-core']['dir'], "etc", "unicorn.rb") %> /opt/gitlab/embedded/service/gitlab-core/config.ru +exec chpst -P -U <%= node['gitlab']['user']['username'] %> -u <%= node['gitlab']['user']['username'] %> /usr/bin/env HOME="<%= node['gitlab']['gitlab-rails']['dir'] %>" /opt/gitlab/embedded/bin/bundle exec unicorn -E <%= node['gitlab']['gitlab-rails']['environment'] %> -c <%= File.join(node['gitlab']['gitlab-rails']['dir'], "etc", "unicorn.rb") %> /opt/gitlab/embedded/service/gitlab-rails/config.ru -- libgit2 0.21.2