Commit 0b8b46791cce1dc1cbb439a522766b612b347759
Exists in
master
and in
17 other branches
Merge branch 'template_link_helper' into 'master'
Template Link Helper
Showing
4 changed files
with
51 additions
and
32 deletions
Show diff stats
files/gitlab-cookbooks/gitlab/definitions/template_symlink.rb
0 → 100644
| ... | ... | @@ -0,0 +1,31 @@ |
| 1 | +# | |
| 2 | +# Copyright:: Copyright (c) 2014 GitLab.com | |
| 3 | +# License:: Apache License, Version 2.0 | |
| 4 | +# | |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); | |
| 6 | +# you may not use this file except in compliance with the License. | |
| 7 | +# You may obtain a copy of the License at | |
| 8 | +# | |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 | |
| 10 | +# | |
| 11 | +# Unless required by applicable law or agreed to in writing, software | |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, | |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 14 | +# See the License for the specific language governing permissions and | |
| 15 | +# limitations under the License. | |
| 16 | +# | |
| 17 | + | |
| 18 | +define :template_symlink, :link_from => nil, :source => nil, :owner => nil, :group => nil, :mode => nil, :variables => nil, :notifies => nil do | |
| 19 | + template params[:name] do | |
| 20 | + source params[:source] | |
| 21 | + owner params[:owner] | |
| 22 | + group params[:group] | |
| 23 | + mode params[:mode] | |
| 24 | + variables params[:variables] | |
| 25 | + notifies *params[:notifies] if params[:notifies] | |
| 26 | + end | |
| 27 | + | |
| 28 | + link params[:link_from] do | |
| 29 | + to params[:name] | |
| 30 | + end | |
| 31 | +end | ... | ... |
files/gitlab-cookbooks/gitlab/recipes/gitlab-core.rb
| ... | ... | @@ -16,6 +16,7 @@ |
| 16 | 16 | # limitations under the License. |
| 17 | 17 | # |
| 18 | 18 | |
| 19 | +gitlab_core_source_dir = "/opt/gitlab/embedded/service/gitlab-core" | |
| 19 | 20 | gitlab_core_dir = node['gitlab']['gitlab-core']['dir'] |
| 20 | 21 | gitlab_core_etc_dir = File.join(gitlab_core_dir, "etc") |
| 21 | 22 | gitlab_core_working_dir = File.join(gitlab_core_dir, "working") |
| ... | ... | @@ -42,23 +43,17 @@ end |
| 42 | 43 | |
| 43 | 44 | should_notify = OmnibusHelper.should_notify?("gitlab-core") |
| 44 | 45 | |
| 45 | -secret_token_config = File.join(gitlab_core_etc_dir, "secret") | |
| 46 | - | |
| 47 | -file secret_token_config do | |
| 48 | - content node['gitlab']['gitlab-core']['secret_token'] | |
| 46 | +template_symlink File.join(gitlab_core_etc_dir, "secret") do | |
| 47 | + link_from File.join(gitlab_core_source_dir, ".secret") | |
| 48 | + source "secret_token.erb" | |
| 49 | 49 | owner "root" |
| 50 | 50 | group "root" |
| 51 | 51 | mode "0644" |
| 52 | 52 | notifies :restart, 'service[gitlab-core]' if should_notify |
| 53 | 53 | end |
| 54 | 54 | |
| 55 | -link "/opt/gitlab/embedded/service/gitlab-core/.secret" do | |
| 56 | - to secret_token_config | |
| 57 | -end | |
| 58 | - | |
| 59 | -database_yml = File.join(gitlab_core_etc_dir, "database.yml") | |
| 60 | - | |
| 61 | -template database_yml do | |
| 55 | +template_symlink File.join(gitlab_core_etc_dir, "database.yml") do | |
| 56 | + link_from File.join(gitlab_core_source_dir, "config/database.yml") | |
| 62 | 57 | source "database.yml.postgresql.erb" |
| 63 | 58 | owner "root" |
| 64 | 59 | group "root" |
| ... | ... | @@ -67,13 +62,8 @@ template database_yml do |
| 67 | 62 | notifies :restart, 'service[gitlab-core]' if should_notify |
| 68 | 63 | end |
| 69 | 64 | |
| 70 | -link "/opt/gitlab/embedded/service/gitlab-core/config/database.yml" do | |
| 71 | - to database_yml | |
| 72 | -end | |
| 73 | - | |
| 74 | -gitlab_yml = File.join(gitlab_core_etc_dir, "gitlab.yml") | |
| 75 | - | |
| 76 | -template gitlab_yml do | |
| 65 | +template_symlink File.join(gitlab_core_etc_dir, "gitlab.yml") do | |
| 66 | + link_from File.join(gitlab_core_source_dir, "config/gitlab.yml") | |
| 77 | 67 | source "gitlab.yml.erb" |
| 78 | 68 | owner "root" |
| 79 | 69 | group "root" |
| ... | ... | @@ -82,13 +72,8 @@ template gitlab_yml do |
| 82 | 72 | notifies :restart, 'service[gitlab-core]' if should_notify |
| 83 | 73 | end |
| 84 | 74 | |
| 85 | -link "/opt/gitlab/embedded/service/gitlab-core/config/gitlab.yml" do | |
| 86 | - to gitlab_yml | |
| 87 | -end | |
| 88 | - | |
| 89 | -rack_attack = File.join(gitlab_core_etc_dir, "rack_attack.rb") | |
| 90 | - | |
| 91 | -template rack_attack do | |
| 75 | +template_symlink File.join(gitlab_core_etc_dir, "rack_attack.rb") do | |
| 76 | + link_from File.join(gitlab_core_source_dir, "config/initializers/rack_attack.rb") | |
| 92 | 77 | source "rack_attack.rb.erb" |
| 93 | 78 | owner "root" |
| 94 | 79 | group "root" |
| ... | ... | @@ -97,10 +82,6 @@ template rack_attack do |
| 97 | 82 | notifies :restart, 'service[gitlab-core]' if should_notify |
| 98 | 83 | end |
| 99 | 84 | |
| 100 | -link "/opt/gitlab/embedded/service/gitlab-core/config/initializers/rack_attack.rb" do | |
| 101 | - to rack_attack | |
| 102 | -end | |
| 103 | - | |
| 104 | 85 | directory node['gitlab']['gitlab-core']['satellites_path'] do |
| 105 | 86 | owner node['gitlab']['user']['username'] |
| 106 | 87 | group node['gitlab']['user']['group'] | ... | ... |
files/gitlab-cookbooks/gitlab/recipes/gitlab-shell.rb
| ... | ... | @@ -19,6 +19,7 @@ |
| 19 | 19 | git_user = node['gitlab']['user']['username'] |
| 20 | 20 | git_group = node['gitlab']['user']['group'] |
| 21 | 21 | gitlab_shell_dir = "/opt/gitlab/embedded/service/gitlab-shell" |
| 22 | +gitlab_shell_var_dir = "/var/opt/gitlab/gitlab-shell" | |
| 22 | 23 | repositories_path = node['gitlab']['gitlab-core']['repositories_path'] |
| 23 | 24 | ssh_dir = File.join(node['gitlab']['user']['home'], ".ssh") |
| 24 | 25 | log_directory = node['gitlab']['gitlab-shell']['log_directory'] |
| ... | ... | @@ -42,10 +43,15 @@ directory log_directory do |
| 42 | 43 | recursive true |
| 43 | 44 | end |
| 44 | 45 | |
| 45 | -template File.join(gitlab_shell_dir, "config.yml") do | |
| 46 | - source "gitlab-shell-config.yml.erb" | |
| 46 | +directory gitlab_shell_var_dir do | |
| 47 | 47 | owner git_user |
| 48 | - group git_group | |
| 48 | + mode '0700' | |
| 49 | + recursive true | |
| 50 | +end | |
| 51 | + | |
| 52 | +template_symlink File.join(gitlab_shell_var_dir, "config.yml") do | |
| 53 | + link_from File.join(gitlab_shell_dir, "config.yml") | |
| 54 | + source "gitlab-shell-config.yml.erb" | |
| 49 | 55 | variables( |
| 50 | 56 | :user => git_user, |
| 51 | 57 | :api_url => node['gitlab']['gitlab-core']['internal_api_url'], | ... | ... |
files/gitlab-cookbooks/gitlab/templates/default/secret_token.erb
0 → 100644
| ... | ... | @@ -0,0 +1 @@ |
| 1 | +<%= node['gitlab']['gitlab-core']['secret_token'] %> | ... | ... |