-
-
Notifications
You must be signed in to change notification settings - Fork 375
/
system.rb
70 lines (62 loc) · 1.79 KB
/
system.rb
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
#
# Cookbook Name:: rvm
# Recipe:: system
#
# Copyright 2010, 2011 Fletcher Nichol
#
# 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.
#
# thanks to:
# - http://www.agileweboperations.com/chef-rvm-ruby-enterprise-edition-as-default-ruby/
# - http://github.com/denimboy/xprdev/blob/master/rvm/recipes/default.rb
script_flags = ""
if node[:rvm][:version]
script_flags += " --version #{node[:rvm][:version]}"
end
if node[:rvm][:branch]
script_flags += " --branch #{node[:rvm][:branch]}"
end
pkgs = %w{ sed grep tar gzip bzip2 bash curl }
case node[:platform]
when "centos","redhat","fedora"
pkgs << "git"
when "debian","ubuntu","suse"
pkgs << "git-core"
end
pkgs.each do |pkg|
package pkg
end
#group "rvm" do
# members node[:rvm][:group_users]
# append true
#end
execute "install system-wide RVM" do
user "root"
command <<-CODE
bash -c "bash <( curl -LB #{node[:rvm][:installer_url]} )#{script_flags}"
CODE
not_if rvm_wrap_cmd(%{type rvm | head -1 | grep -q '^rvm is a function$'})
end
template "/etc/rvmrc" do
source "rvmrc.erb"
owner "root"
group "rvm"
mode "0644"
end
execute "upgrade RVM to #{node[:rvm][:upgrade]}" do
user "root"
command rvm_wrap_cmd(%{rvm get #{node[:rvm][:upgrade]}})
only_if do
%{ latest head }.include? node[:rvm][:upgrade]
end
end