Skip to content

Commit a953235

Browse files
authored
Merge pull request #125 from yakara-ltd/8-14
GitLab 8.14, GitLab Shell 4.0.2, migration to GitLab Workhorse, other fixes
2 parents ae4ee23 + dff6e2e commit a953235

File tree

11 files changed

+393
-286
lines changed

11 files changed

+393
-286
lines changed

README.md

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,6 @@ Attributes
7373
* `gitlab['email_from']`
7474
- Gitlab email from, default `gitlab@ + node.fqdn`
7575

76-
* `gitlab['support_email']`
77-
- Gitlab support email, default `gitlab-support@ + node.fqdn`
78-
7976
* `gitlab['git_url']`
8077
- Github gitlab address, default https://github.com/gitlabhq/gitlabhq.git
8178

@@ -128,11 +125,6 @@ Attributes
128125
See [nginx server_name documentation](http://nginx.org/en/docs/http/server_names.html)
129126
for valid matching patterns.
130127

131-
* `gitlab['gravatar']['enabled']`
132-
- Use Gravatar to fetch user avatars
133-
- Options: "true", "false"
134-
- Default "true"
135-
136128
* `gitlab['unicorn']['timeout']`
137129
- Timeout in seconds to Unicorn
138130
- Default: 60
@@ -145,11 +137,6 @@ Attributes
145137

146138
**Note**, This attributes are useful when you want only admins to create projects and groups. And to restrict username changing.
147139

148-
* `gitlab['default_projects_limit']`
149-
- When you create a user this value is their `projects_limit` profile setting.
150-
- If you put it at 0, regular users can't create repos.
151-
- Default, 10.
152-
153140
* `gitlab['default_can_create_group']`
154141
- When you create a user this value is their `can_create_group` profile setting.
155142
- Default, true.

attributes/default.rb

Lines changed: 58 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,20 @@
2626
default['gitlab']['web_fqdn'] = node['fqdn']
2727
default['gitlab']['nginx_server_names'] = ['gitlab.*', node['fqdn']]
2828
default['gitlab']['email_from'] = "gitlab@#{node['domain']}"
29-
default['gitlab']['support_email'] = "gitlab-support@#{node['domain']}"
3029
default['gitlab']['unicorn']['timeout'] = 60
3130

3231
# User default privileges
33-
default['gitlab']['default_projects_limit'] = 10
3432
default['gitlab']['default_can_create_group'] = true
3533
default['gitlab']['username_changing_enabled'] = true
3634

3735
# Set github URL for gitlab
3836
default['gitlab']['git_url'] = 'https://github.com/gitlabhq/gitlabhq.git'
39-
default['gitlab']['git_branch'] = '8-5-stable'
37+
default['gitlab']['git_branch'] = '8-14-stable'
4038

4139
# gitlab-shell attributes
4240
default['gitlab']['shell']['home'] = node['gitlab']['home'] + '/gitlab-shell'
4341
default['gitlab']['shell']['git_url'] = 'https://github.com/gitlabhq/gitlab-shell.git'
44-
default['gitlab']['shell']['git_branch'] = 'v2.6.10'
42+
default['gitlab']['shell']['git_branch'] = 'v4.0.2'
4543
default['gitlab']['shell']['gitlab_host'] = nil
4644

4745
# Database setup
@@ -55,52 +53,75 @@
5553
default['gitlab']['database']['database'] = 'gitlab'
5654
default['gitlab']['database']['username'] = 'gitlab'
5755
default['gitlab']['database']['userhost'] = '127.0.0.1'
58-
default['gitlab']['postgresql']['username'] = 'postgres'
59-
default['gitlab']['database']['password'] = 'changeme'
56+
default['gitlab']['database']['password'] = nil
6057

6158
# Ruby setup
6259
include_attribute 'ruby_build'
6360
default['ruby_build']['upgrade'] = 'sync'
64-
default['gitlab']['install_ruby'] = '2.1.8'
61+
default['gitlab']['install_ruby'] = '2.3.3'
6562
default['gitlab']['install_ruby_path'] = node['gitlab']['home']
6663
default['gitlab']['cookbook_dependencies'] = %w(
67-
zlib readline ncurses openssh
68-
logrotate redisio::default redisio::enable ruby_build
64+
zlib
65+
readline
66+
ncurses
67+
openssh
68+
logrotate
69+
redisio::default
70+
redisio::enable
71+
ruby_build
6972
)
7073

7174
# Redisio instance name
7275
default['gitlab']['redis_instance'] = 'redis-server'
7376

7477
# Required packages for Gitlab
78+
default['gitlab']['packages'] = %w(
79+
cmake
80+
curl
81+
golang
82+
nodejs
83+
python-docutils
84+
sudo
85+
wget
86+
)
7587
case node['platform_family']
7688
when 'debian'
77-
default['gitlab']['packages'] = %w(
78-
libyaml-dev libssl-dev libgdbm-dev libffi-dev checkinstall
79-
curl libcurl4-openssl-dev libicu-dev wget python-docutils sudo
80-
cmake libkrb5-dev pkg-config nodejs
89+
default['gitlab']['packages'] += %w(
90+
checkinstall
91+
libcurl4-openssl-dev
92+
libffi-dev
93+
libgdbm-dev
94+
libicu-dev
95+
libkrb5-dev
96+
libssl-dev
97+
libyaml-dev
98+
pkg-config
8199
)
82100
when 'rhel'
83-
default['gitlab']['packages'] = %w(
84-
libyaml-devel openssl-devel gdbm-devel libffi-devel
85-
curl libcurl-devel libicu-devel wget python-docutils sudo
86-
cmake krb5-devel pkgconfig nodejs jemalloc jemalloc-devel
87-
)
88-
else
89-
default['gitlab']['install_ruby'] = 'package'
90-
default['gitlab']['cookbook_dependencies'] = %w(
91-
openssh readline zlib ruby_build
92-
redisio::default redisio::enable
93-
)
94-
default['gitlab']['packages'] = %w(
95-
autoconf binon flex gcc gcc-c++ make m4 cmake
96-
git
97-
zlib1g-dev libyaml-dev libssl-dev libgdbm-dev
98-
libreadline-dev libncurses5-dev libffi-dev curl git-core openssh-server
99-
redis-server checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev
100-
libicu-dev python-docutils sudo libkrb5-dev pkg-config nodejs
101+
default['gitlab']['packages'] += %w(
102+
gdbm-devel
103+
jemalloc
104+
jemalloc-devel
105+
krb5-devel
106+
libcurl-devel
107+
libffi-devel
108+
libicu-devel
109+
libyaml-devel
110+
openssl-devel
111+
pkgconfig
101112
)
102113
end
103114

115+
# How to install git? RHEL 7 can use End Point.
116+
default['gitlab']['git_recipe'] = value_for_platform(
117+
%w( redhat centos scientific oracle ) => { '< 7' => 'source' },
118+
'amazon' => { '>= 0' => 'source' },
119+
'fedora' => { '< 24' => 'source' },
120+
'debian' => { '< 9' => 'source' },
121+
'ubuntu' => { '< 16.04' => 'source' },
122+
'default' => 'package'
123+
)
124+
104125
default['gitlab']['trust_local_sshkeys'] = 'yes'
105126

106127
default['gitlab']['https'] = false
@@ -133,19 +154,16 @@
133154
default['gitlab']['ldap']['allow_username_or_email_login'] = true
134155
default['gitlab']['ldap']['user_filter'] = ''
135156

136-
# Secrets
137-
default['gitlab']['secrets']['production_db_key_base'] = 'production' # UPDATE THIS, at least 30 chars. Used to encrypt Variables.
138-
139-
# Gravatar
140-
default['gitlab']['gravatar']['enabled'] = true
141-
142157
# Mysql
143158
default['mysql']['server_root_password'] = 'Ch4ngm3'
144159
default['build-essential']['compile_time'] = true # needed for mysql chef_gem
145160

161+
# PostgreSQL
162+
default['postgresql']['contrib']['extensions'] = ['pg_trgm']
163+
146164
# nginx
147165
default['nginx']['default_site_enabled'] = false
148166

149-
# Gitlab git http server
150-
default['gitlab']['git_http_server_revision'] = 'master'
151-
default['gitlab']['git_http_server_repository'] = 'https://gitlab.com/gitlab-org/gitlab-git-http-server.git'
167+
# GitLab Workhorse
168+
default['gitlab']['workhorse_revision'] = 'v1.0.1'
169+
default['gitlab']['workhorse_repository'] = 'https://gitlab.com/gitlab-org/gitlab-workhorse.git'

metadata.rb

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,33 @@
44
description 'Installs/Configures gitlab'
55
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
66
name 'gitlab'
7-
version '8.5.0'
7+
version '8.14.0'
88
issues_url 'https://github.com/atomic-penguin/cookbook-gitlab/issues'
99
source_url 'https://github.com/atomic-penguin/cookbook-gitlab'
1010

11-
%w(build-essential zlib readline ncurses git openssh redisio xml
12-
ruby_build certificate database logrotate
13-
postgresql apt yum-epel selinux_policy).each do |cb_depend|
11+
%w(
12+
apt
13+
build-essential
14+
certificate
15+
database
16+
git
17+
logrotate
18+
ncurses
19+
openssh
20+
postgresql
21+
readline
22+
redisio
23+
ruby_build
24+
selinux_policy
25+
xml
26+
yum-epel
27+
zlib
28+
).each do |cb_depend|
1429
depends cb_depend
1530
end
1631
depends 'mysql', '~> 6.0'
1732
depends 'mysql2_chef_gem'
18-
depends 'nginx', '<3'
33+
depends 'nginx', '~> 2.7'
1934

2035
%w(redhat centos scientific amazon debian ubuntu).each do |os|
2136
supports os

recipes/default.rb

Lines changed: 20 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
include_recipe 'yum-epel'
2626
end
2727

28+
# Install new enough git version
29+
include_recipe 'gitlab::git'
30+
2831
# Setup the database connection
2932
case node['gitlab']['database']['type']
3033
when 'mysql'
@@ -45,9 +48,7 @@
4548
end
4649

4750
# Install required packages for Gitlab
48-
node['gitlab']['packages'].each do |pkg|
49-
package pkg
50-
end
51+
package node['gitlab']['packages']
5152

5253
# Add a git user for Gitlab
5354
user node['gitlab']['user'] do
@@ -217,9 +218,9 @@ class file open;
217218
# Write the database.yml
218219
template "#{node['gitlab']['app_home']}/config/database.yml" do
219220
source 'database.yml.erb'
220-
owner node['gitlab']['user']
221+
owner 'root'
221222
group node['gitlab']['group']
222-
mode '0644'
223+
mode '0640'
223224
variables(
224225
adapter: node['gitlab']['database']['adapter'],
225226
encoding: node['gitlab']['database']['encoding'],
@@ -248,16 +249,6 @@ class file open;
248249
)
249250
end
250251

251-
# Render gitlab secrets file
252-
template "#{node['gitlab']['app_home']}/config/secrets.yml" do
253-
owner node['gitlab']['user']
254-
group node['gitlab']['group']
255-
mode '0600'
256-
variables(
257-
production_db_key_base: node['gitlab']['secrets']['production_db_key_base']
258-
)
259-
end
260-
261252
# Copy file rack_attack.rb
262253
cookbook_file "#{node['gitlab']['app_home']}/config/initializers/rack_attack.rb" do
263254
owner node['gitlab']['user']
@@ -367,62 +358,26 @@ class unix_stream_socket connectto;
367358
not_if { File.exist?(bundle_success) }
368359
end
369360

370-
# Install Gitlab Git HTTP server
371-
372-
## get Go 1.5 # TODO, for future PR find cookbook for Go ie: https://github.com/NOX73/chef-golang
373-
golang_package = 'https://storage.googleapis.com/golang/go1.5.linux-amd64.tar.gz'
374-
temp_golangpkg = '/tmp/gitlab_git_http_server.tar'
375-
376-
remote_file temp_golangpkg do
377-
source golang_package
378-
# checksum node['']['']['checksum']
379-
owner 'root'
380-
group 'root'
381-
mode '0755'
382-
notifies :run, 'bash[extract_golang]', :immediately
383-
not_if { ::File.exist?('/usr/local/bin/go') }
384-
end
385-
386-
bash 'extract_golang' do
387-
action :run
388-
cwd ::File.dirname(node['gitlab']['home'])
389-
code <<-EOH
390-
tar -C /usr/local -xzf #{temp_golangpkg}
391-
rm -f #{temp_golangpkg}
392-
EOH
393-
not_if { ::File.exist?('/usr/local/bin/go') }
394-
end
395-
396-
%w(go godoc gofmt).each do |l|
397-
link "/usr/local/bin/#{l}" do
398-
to "/usr/local/go/bin/#{l}"
399-
not_if "test -e /usr/local/bin/#{l}"
400-
only_if "test -e /usr/local/go/bin/#{l}"
401-
# not_if {File.exists?("/usr/local/bin/#{l}")}
402-
# only_if {File.exists?("/usr/local/go/bin/#{l}")}
403-
end
404-
end
405-
406-
# Install gitlab git http server
407-
git "#{node['gitlab']['home']}/gitlab-git-http-server" do
408-
# default repository 'https://gitlab.com/gitlab-org/gitlab-git-http-server.git
409-
repository node['gitlab']['git_http_server_repository']
410-
revision node['gitlab']['git_http_server_revision']
361+
# Install GitLab Workhorse
362+
git "#{node['gitlab']['home']}/gitlab-workhorse" do
363+
# default repository 'https://gitlab.com/gitlab-org/gitlab-workhorse.git
364+
repository node['gitlab']['workhorse_repository']
365+
revision node['gitlab']['workhorse_revision']
411366
action :sync
412367
user node['gitlab']['user']
413368
group node['gitlab']['group']
414-
notifies :run, 'bash[compile-git-http-server]', :immediately
369+
notifies :run, 'bash[compile-workhorse]', :immediately
415370
end
416371

417-
bash 'compile-git-http-server' do
372+
bash 'compile-workhorse' do
418373
action :run
419-
cwd "#{node['gitlab']['home']}/gitlab-git-http-server"
374+
cwd "#{node['gitlab']['home']}/gitlab-workhorse"
420375
code <<-EOH
421376
make
422377
EOH
423378
user node['gitlab']['user']
424379
group node['gitlab']['group']
425-
not_if { ::File.exist?("#{node['gitlab']['home']}/gitlab-git-http-server/gitlab-git-http-server") }
380+
not_if { ::File.exist?("#{node['gitlab']['home']}/gitlab-workhorse/gitlab-workhorse") }
426381
end
427382

428383
# Precompile assets
@@ -437,7 +392,11 @@ class unix_stream_socket connectto;
437392

438393
# Initialize database
439394
execute 'gitlab-bundle-rake' do
440-
command "#{bundler_binary} exec rake gitlab:setup RAILS_ENV=production force=yes && touch .gitlab-setup"
395+
# Check the task list below against setup.rake. We can't use
396+
# gitlab:setup because db:reset DROPs the database and we don't want
397+
# to give the database user permission to create new databases.
398+
# https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/tasks/gitlab/setup.rake
399+
command "#{bundler_binary} exec rake db:schema:load add_limits_mysql setup_postgresql db:seed_fu RAILS_ENV=production && touch .gitlab-setup"
441400
cwd node['gitlab']['app_home']
442401
user node['gitlab']['user']
443402
group node['gitlab']['group']

recipes/git.rb

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#
2+
# Cookbook Name:: gitlab
3+
# Recipe:: git
4+
#
5+
# Copyright 2016, Yakara Ltd
6+
#
7+
# Licensed under the Apache License, Version 2.0 (the "License");
8+
# you may not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
#
19+
20+
git_recipe = node['gitlab']['git_recipe']
21+
22+
yum_repository 'endpoint-git' do
23+
description 'git from End Point repository'
24+
includepkgs 'git git-core* perl-Git'
25+
el = node['platform_version'].to_i
26+
baseurl "https://packages.endpoint.com/rhel/#{el}/os/$basearch/"
27+
gpgkey "https://packages.endpoint.com/endpoint-rpmsign-#{el}.pub"
28+
only_if { git_recipe == 'package' && platform_family?('rhel') }
29+
end
30+
31+
include_recipe "git::#{git_recipe}"

0 commit comments

Comments
 (0)