Skip to content

Commit

Permalink
Use rbenv for ruby
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Lamontagne committed Jun 18, 2013
1 parent d4b7c1c commit c9b8bb7
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 47 deletions.
15 changes: 6 additions & 9 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
case node['platform']
when "ubuntu","debian"
default['gitlab']['packages'] = %w{
ruby1.9.1 ruby1.9.1-dev ri1.9.1 libruby1.9.1
curl wget checkinstall libxslt-dev libsqlite3-dev
libcurl4-openssl-dev libssl-dev libmysql++-dev
libicu-dev libc6-dev libyaml-dev nginx python python-dev
Expand All @@ -62,7 +61,6 @@
end
else
default['gitlab']['packages'] = %w{
ruby1.9.1 ruby1.9.1-dev ri1.9.1 libruby1.9.1
curl wget checkinstall libxslt-dev libsqlite3-dev
libcurl4-openssl-dev libssl-dev libmysql++-dev
libicu-dev libc6-dev libyaml-dev nginx python
Expand All @@ -72,13 +70,7 @@

default['gitlab']['trust_local_sshkeys'] = "yes"

# Problems deploying this on RedHat provided rubies.
case node['platform']
when "redhat","centos","scientific","amazon"
default['gitlab']['install_ruby'] = "1.9.2-p290"
else
default['gitlab']['install_ruby'] = "package"
end
default['gitlab']['install_ruby'] = "1.9.3-p429"

default['gitlab']['https'] = false
default['gitlab']['ssl_certificate'] = "/etc/nginx/#{node['fqdn']}.crt"
Expand All @@ -90,3 +82,8 @@

# workers for puma "cluster mode", see config/puma.rb
default['gitlab']['puma_wokers'] = 0

# rbenv
node.default['rbenv']['user_installs'] = [
{ 'user' => default['gitlab']['user'] }
]
2 changes: 1 addition & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
%w{ gitolite nginx }.each do |cb_conflict|
conflicts cb_conflict
end
%w{ yumrepo ruby_build git redisio build-essential python readline sudo openssh perl xml zlib database mysql postgresql }.each do |cb_depend|
%w{ yumrepo ruby_build rbenv git redisio build-essential python readline sudo openssh perl xml zlib database mysql postgresql }.each do |cb_depend|
depends cb_depend
end
%w{ redhat centos scientific amazon debian ubuntu }.each do |os|
Expand Down
73 changes: 36 additions & 37 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,6 @@
to "/usr/local/bin/redis-cli"
end

# There are problems deploying on Redhat provided rubies.
# We'll use Fletcher Nichol's slick ruby_build cookbook to compile a Ruby.
if node['gitlab']['install_ruby'] !~ /package/
ruby_build_ruby node['gitlab']['install_ruby']

# Drop off a profile script.
template "/etc/profile.d/gitlab.sh" do
owner "root"
group "root"
mode 0755
variables(
:fqdn => node['fqdn'],
:install_ruby => node['gitlab']['install_ruby']
)
end

# Set PATH for remainder of recipe.
ENV['PATH'] = "/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/ruby/#{node['gitlab']['install_ruby']}/bin"
end

# Install required packages for Gitlab
node['gitlab']['packages'].each do |pkg|
package pkg
Expand All @@ -65,12 +45,6 @@
action :install
end

# Install required Ruby Gems for Gitlab
%w{ charlock_holmes bundler }.each do |gempkg|
gem_package gempkg do
action :install
end
end

# Install pygments from pip
python_pip "pygments" do
Expand All @@ -97,6 +71,31 @@
members node['gitlab']['user']
end

# setup rbenv (after git user setup)
%w{ ruby_build rbenv::user_install }.each do |requirement|
include_recipe requirement
end

# Install appropriate Ruby with rbenv
rbenv_ruby node['gitlab']['install_ruby'] do
action :install
user node['gitlab']['user']
end

# Set as the rbenv default ruby
rbenv_global node['gitlab']['install_ruby'] do
user node['gitlab']['user']
end

# Install required Ruby Gems for Gitlab (via rbenv)
%w{ charlock_holmes bundler }.each do |gempkg|
rbenv_gem gempkg do
action :install
user node['gitlab']['user']
rbenv_version node['gitlab']['install_ruby']
end
end

# Create a $HOME/.ssh folder
directory "#{node['gitlab']['home']}/.ssh" do
owner node['gitlab']['user']
Expand Down Expand Up @@ -204,6 +203,17 @@
)
end

without_group = node['gitlab']['database']['type'] == 'mysql' ? 'postgres' : 'mysql'

# Install Gems with bundle install
execute "gitlab-bundle-install" do
command "bundle install --without development test #{without_group} --deployment"
cwd node['gitlab']['app_home']
user node['gitlab']['user']
group node['gitlab']['group']
environment({ 'LANG' => "en_US.UTF-8", 'LC_ALL' => "en_US.UTF-8" })
not_if { File.exists?("#{node['gitlab']['app_home']}/vendor/bundle") }
end
# Setup the database
case node['gitlab']['database']['type']
when 'mysql'
Expand Down Expand Up @@ -239,17 +249,6 @@
)
end

without_group = node['gitlab']['database'] == 'mysql' ? 'postgres' : 'mysql'

# Install Gems with bundle install
execute "gitlab-bundle-install" do
command "bundle install --without development test #{without_group} --deployment"
cwd node['gitlab']['app_home']
user node['gitlab']['user']
group node['gitlab']['group']
environment({ 'LANG' => "en_US.UTF-8", 'LC_ALL' => "en_US.UTF-8" })
not_if { File.exists?("#{node['gitlab']['app_home']}/vendor/bundle") }
end

# Setup sqlite database for Gitlab
execute "gitlab-bundle-rake" do
Expand Down

0 comments on commit c9b8bb7

Please sign in to comment.