default.rb
2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
if node['platform'] == 'centos'
cookbook_file '/etc/yum.repos.d/gitlab.repo' do
action :delete
end
end
package 'gitlab' do
action :upgrade
notifies :restart, 'service[gitlab]'
end
template '/etc/gitlab/database.yml' do
owner 'root'
group 'root'
mode 0644
notifies :run, 'execute[gitlab:setup]', :immediately
end
execute 'gitlab:setup' do
user 'git'
cwd '/usr/lib/gitlab'
command 'yes yes | bundle exec rake db:setup RAILS_ENV=production && touch /var/lib/gitlab/setup.done'
not_if { File.exists?('/var/lib/gitlab/setup.done') }
action :nothing
notifies :restart, 'service[gitlab]'
end
# gitlab-shell configuration
template '/etc/gitlab-shell/config.yml' do
source 'gitlab-shell.yml.erb'
owner 'root'
group 'root'
mode 0644
notifies :restart, 'service[gitlab]'
end
# gitlab redis configuration
template '/usr/lib/gitlab/config/resque.yml' do
owner 'root'
group 'root'
mode 0644
notifies :restart, 'service[gitlab]'
end
####################################################
# Run under /gitlab
####################################################
template '/etc/gitlab/gitlab.yml' do
owner 'root'
group 'root'
mode 0644
notifies :restart, 'service[gitlab]'
end
cookbook_file '/usr/lib/gitlab/config/initializers/gitlab_path.rb' do
owner 'root'
group 'root'
mode 0644
notifies :restart, 'service[gitlab]'
end
cookbook_file '/etc/gitlab/unicorn.rb' do
owner 'root'
group 'root'
mode 0644
notifies :restart, 'service[gitlab]'
end
####################################################
# Run under /gitlab (END)
####################################################
# serve static files with nginx
template '/etc/nginx/conf.d/gitlab.conf' do
source 'nginx.conf.erb'
mode 0644
notifies :reload, 'service[nginx]'
end
service 'gitlab' do
action :enable
supports :restart => true
end
####################################################
# SELinux: allow gitlab to use '/tmp'
####################################################
cookbook_file '/etc/selinux/local/gitlab.te' do
notifies :run, 'execute[selinux-gitlab]'
end
execute 'selinux-gitlab' do
command 'selinux-install-module /etc/selinux/local/gitlab.te'
action :nothing
end
execute 'fix-relative-url-for-assets' do
command 'sed -i \'s/# config.relative_url_root = "\/gitlab"/config.relative_url_root = "\/gitlab"/\' /usr/lib/gitlab/config/application.rb'
only_if 'grep -q "# config.relative_url_root" /usr/lib/gitlab/config/application.rb'
notifies :run, 'execute[precompile-assets]'
end
execute 'change-cache-owner' do
command 'chown -R git:git /usr/lib/gitlab/tmp/cache'
only_if 'ls -l /usr/lib/gitlab/tmp/cache | grep root'
end
execute 'precompile-assets' do
user 'git'
cwd '/usr/lib/gitlab'
command 'bundle exec rake assets:precompile RAILS_ENV=production'
action :nothing
end