flombe 0.1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +4 -0
- data/.gitmodules +3 -0
- data/.rspec +2 -0
- data/Flombefile +9 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +57 -0
- data/LICENSE +20 -0
- data/Rakefile +33 -0
- data/bin/flombe +17 -0
- data/config/rake.rb +38 -0
- data/cookbooks/homebrew/README.rdoc +8 -0
- data/cookbooks/homebrew/metadata.rb +8 -0
- data/cookbooks/homebrew/providers/homebrew.rb +39 -0
- data/cookbooks/homebrew/recipes/default.rb +42 -0
- data/cookbooks/homebrew/resources/homebrew.rb +14 -0
- data/cookbooks/mysql/README.rdoc +8 -0
- data/cookbooks/mysql/metadata.rb +6 -0
- data/cookbooks/mysql/recipes/default.rb +43 -0
- data/cookbooks/mysql/recipes/timezone.rb +10 -0
- data/cookbooks/redis/README.rdoc +8 -0
- data/cookbooks/redis/metadata.rb +6 -0
- data/cookbooks/redis/recipes/2.0.4.rb +24 -0
- data/cookbooks/redis/recipes/default.rb +7 -0
- data/cookbooks/rvm/CHANGELOG.md +19 -0
- data/cookbooks/rvm/README.md +564 -0
- data/cookbooks/rvm/Rakefile +35 -0
- data/cookbooks/rvm/attributes/default.rb +54 -0
- data/cookbooks/rvm/attributes/gem_package.rb +23 -0
- data/cookbooks/rvm/attributes/vagrant.rb +22 -0
- data/cookbooks/rvm/libraries/gem_package_monkeypatch.rb +34 -0
- data/cookbooks/rvm/libraries/helpers.rb +334 -0
- data/cookbooks/rvm/libraries/rvm_rubygems_package.rb +108 -0
- data/cookbooks/rvm/metadata.json +271 -0
- data/cookbooks/rvm/metadata.rb +95 -0
- data/cookbooks/rvm/providers/default_ruby.rb +46 -0
- data/cookbooks/rvm/providers/environment.rb +50 -0
- data/cookbooks/rvm/providers/gemset.rb +135 -0
- data/cookbooks/rvm/providers/global_gem.rb +99 -0
- data/cookbooks/rvm/providers/ruby.rb +100 -0
- data/cookbooks/rvm/providers/shell.rb +68 -0
- data/cookbooks/rvm/providers/wrapper.rb +58 -0
- data/cookbooks/rvm/recipes/default.rb +73 -0
- data/cookbooks/rvm/recipes/gem_package.rb +23 -0
- data/cookbooks/rvm/recipes/system.rb +69 -0
- data/cookbooks/rvm/recipes/user.rb +47 -0
- data/cookbooks/rvm/recipes/vagrant.rb +30 -0
- data/cookbooks/rvm/resources/default_ruby.rb +29 -0
- data/cookbooks/rvm/resources/environment.rb +29 -0
- data/cookbooks/rvm/resources/gem.rb +36 -0
- data/cookbooks/rvm/resources/gemset.rb +30 -0
- data/cookbooks/rvm/resources/global_gem.rb +33 -0
- data/cookbooks/rvm/resources/ruby.rb +29 -0
- data/cookbooks/rvm/resources/shell.rb +40 -0
- data/cookbooks/rvm/resources/wrapper.rb +32 -0
- data/cookbooks/rvm/templates/default/rvmrc.erb +14 -0
- data/cookbooks/rvm/templates/default/vagrant-chef-solo-wrapper.erb +23 -0
- data/cookbooks/utils/README.rdoc +8 -0
- data/cookbooks/utils/metadata.rb +6 -0
- data/cookbooks/utils/recipes/default.rb +10 -0
- data/cookbooks/utils/recipes/dotfiles.rb +21 -0
- data/cookbooks/utils/templates/default/dot.profile.erb +36 -0
- data/flombe.gemspec +28 -0
- data/lib/flombe/dsl.rb +66 -0
- data/lib/flombe.rb +107 -0
- data/spec/dsl_spec.rb +111 -0
- data/spec/flombe_spec.rb +30 -0
- data/spec/quality_spec.rb +11 -0
- data/spec/spec_helper.rb +21 -0
- data/spec/support/helpers.rb +18 -0
- data/spec/support/matchers.rb +9 -0
- data/spec/support/path.rb +21 -0
- data/templates/chef_solo.erb +11 -0
- metadata +154 -0
@@ -0,0 +1,99 @@
|
|
1
|
+
#
|
2
|
+
# Cookbook Name:: rvm
|
3
|
+
# Provider:: global_gem
|
4
|
+
#
|
5
|
+
# Author:: Fletcher Nichol <fnichol@nichol.ca>
|
6
|
+
#
|
7
|
+
# Copyright 2011, Fletcher Nichol
|
8
|
+
#
|
9
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
10
|
+
# you may not use this file except in compliance with the License.
|
11
|
+
# You may obtain a copy of the License at
|
12
|
+
#
|
13
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
14
|
+
#
|
15
|
+
# Unless required by applicable law or agreed to in writing, software
|
16
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
17
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
18
|
+
# See the License for the specific language governing permissions and
|
19
|
+
# limitations under the License.
|
20
|
+
#
|
21
|
+
|
22
|
+
action :install do
|
23
|
+
# add gem entry into global.gems
|
24
|
+
update_global_gems_file :create
|
25
|
+
|
26
|
+
# install gem in all rubies in global gemsets
|
27
|
+
installed_rubies.each do |rubie|
|
28
|
+
gem_package_wrapper :install, "#{rubie}@global"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
action :upgrade do
|
33
|
+
# add gem entry into global.gems
|
34
|
+
update_global_gems_file :create
|
35
|
+
|
36
|
+
# upgrade gem in all rubies in global gemsets
|
37
|
+
installed_rubies.each do |rubie|
|
38
|
+
gem_package_wrapper :upgrade, "#{rubie}@global"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
action :remove do
|
43
|
+
# remove gem entry from global.gems
|
44
|
+
update_global_gems_file :remove
|
45
|
+
|
46
|
+
# remove gem in all rubies in global gemsets
|
47
|
+
installed_rubies.each do |rubie|
|
48
|
+
gem_package_wrapper :remove, "#{rubie}@global"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
action :purge do
|
53
|
+
# remove gem entry from global.gems
|
54
|
+
update_global_gems_file :remove
|
55
|
+
|
56
|
+
# remove gem in all rubies in global gemsets
|
57
|
+
installed_rubies.each do |rubie|
|
58
|
+
gem_package_wrapper :purge, "#{rubie}@global"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
##
|
63
|
+
# Wraps the rvm_gem resource
|
64
|
+
#
|
65
|
+
# @param [Symbol] action to be performed with gem_package provider
|
66
|
+
# @param [optional, String, #to_s] the fully qualifed rvm string
|
67
|
+
def gem_package_wrapper(exec_action, ruby_global_gemset)
|
68
|
+
profile = find_profile_to_source
|
69
|
+
|
70
|
+
g = rvm_gem new_resource.package_name do
|
71
|
+
ruby_string ruby_global_gemset
|
72
|
+
source new_resource.source if new_resource.source
|
73
|
+
options new_resource.options if new_resource.options
|
74
|
+
version new_resource.version if new_resource.version
|
75
|
+
gem_binary new_resource.gem_binary if new_resource.gem_binary
|
76
|
+
action :nothing
|
77
|
+
end
|
78
|
+
g.run_action(exec_action)
|
79
|
+
end
|
80
|
+
|
81
|
+
##
|
82
|
+
# Updates global.gems file to create or remove a gem entry
|
83
|
+
#
|
84
|
+
# @oaram [Symbol] action to :create or :remove the gem from the file
|
85
|
+
def update_global_gems_file(exec_action)
|
86
|
+
global_gems_file = "#{node['rvm']['root_path']}/gemsets/global.gems"
|
87
|
+
gem = new_resource.package_name
|
88
|
+
|
89
|
+
if exec_action == :create
|
90
|
+
e = execute "Add #{gem} to #{global_gems_file}" do
|
91
|
+
user node['rvm']['user']
|
92
|
+
group node['rvm']['group']
|
93
|
+
command %{echo "#{gem}" >> "#{global_gems_file}"}
|
94
|
+
not_if %{grep -q "^#{gem}" "#{global_gems_file}"}
|
95
|
+
action :nothing
|
96
|
+
end
|
97
|
+
e.run_action(:run)
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
#
|
2
|
+
# Cookbook Name:: rvm
|
3
|
+
# Provider:: ruby
|
4
|
+
#
|
5
|
+
# Author:: Fletcher Nichol <fnichol@nichol.ca>
|
6
|
+
#
|
7
|
+
# Copyright 2011, Fletcher Nichol
|
8
|
+
#
|
9
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
10
|
+
# you may not use this file except in compliance with the License.
|
11
|
+
# You may obtain a copy of the License at
|
12
|
+
#
|
13
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
14
|
+
#
|
15
|
+
# Unless required by applicable law or agreed to in writing, software
|
16
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
17
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
18
|
+
# See the License for the specific language governing permissions and
|
19
|
+
# limitations under the License.
|
20
|
+
#
|
21
|
+
|
22
|
+
action :install do
|
23
|
+
rubie = select_ruby(new_resource.ruby_string)
|
24
|
+
|
25
|
+
if ruby_unknown?(rubie)
|
26
|
+
Chef::Log.warn("rvm_ruby[#{rubie}] is either not fully qualified or not " +
|
27
|
+
"known . Use `rvm list known` to get a full list.")
|
28
|
+
elsif ruby_installed?(rubie)
|
29
|
+
Chef::Log.debug("rvm_ruby[#{rubie}] is already installed, so skipping")
|
30
|
+
else
|
31
|
+
install_start = Time.now
|
32
|
+
|
33
|
+
install_ruby_dependencies rubie
|
34
|
+
|
35
|
+
Chef::Log.info("Building rvm_ruby[#{rubie}], this could take awhile...")
|
36
|
+
|
37
|
+
if RVM.install(rubie)
|
38
|
+
Chef::Log.info("Installation of rvm_ruby[#{rubie}] was successful.")
|
39
|
+
env = RVM::Environment.new
|
40
|
+
env.use rubie
|
41
|
+
update_installed_rubies
|
42
|
+
|
43
|
+
Chef::Log.info("Importing initial gemsets for rvm_ruby[#{rubie}]")
|
44
|
+
if env.gemset_initial
|
45
|
+
Chef::Log.debug("Initial gemsets for rvm_ruby[#{rubie}] are installed")
|
46
|
+
else
|
47
|
+
Chef::Log.warn(
|
48
|
+
"Failed to install initial gemsets for rvm_ruby[#{rubie}] ")
|
49
|
+
end
|
50
|
+
else
|
51
|
+
Chef::Log.warn("Failed to install rvm_ruby[#{rubie}]. " +
|
52
|
+
"Check logs in #{RVM.path}/log/#{rubie}")
|
53
|
+
end
|
54
|
+
|
55
|
+
Chef::Log.debug("rvm_ruby[#{rubie}] build time was " +
|
56
|
+
"#{(Time.now - install_start)/60.0} minutes.")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
action :uninstall do
|
61
|
+
rubie = new_resource.ruby_string
|
62
|
+
|
63
|
+
if ruby_unknown?(rubie)
|
64
|
+
Chef::Log.warn("rvm_ruby[#{rubie}] is either not fully qualified or not " +
|
65
|
+
"known . Use `rvm list known` to get a full list.")
|
66
|
+
elsif ruby_installed?(rubie)
|
67
|
+
Chef::Log.info("Uninstalling rvm_ruby[#{rubie}]")
|
68
|
+
|
69
|
+
if RVM.uninstall(rubie)
|
70
|
+
update_installed_rubies
|
71
|
+
Chef::Log.debug("Uninstallation of rvm_ruby[#{rubie}] was successful.")
|
72
|
+
else
|
73
|
+
Chef::Log.warn("Failed to uninstall rvm_ruby[#{rubie}]. " +
|
74
|
+
"Check logs in #{RVM.path}/log/#{rubie}")
|
75
|
+
end
|
76
|
+
else
|
77
|
+
Chef::Log.debug("rvm_ruby[#{rubie}] was not installed, so skipping")
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
action :remove do
|
82
|
+
rubie = new_resource.ruby_string
|
83
|
+
|
84
|
+
if ruby_unknown?(rubie)
|
85
|
+
Chef::Log.warn("rvm_ruby[#{rubie}] is either not fully qualified or not " +
|
86
|
+
"known . Use `rvm list known` to get a full list.")
|
87
|
+
elsif ruby_installed?(rubie)
|
88
|
+
Chef::Log.info("Removing rvm_ruby[#{rubie}]")
|
89
|
+
|
90
|
+
if RVM.remove(rubie)
|
91
|
+
update_installed_rubies
|
92
|
+
Chef::Log.debug("Removal of rvm_ruby[#{rubie}] was successful.")
|
93
|
+
else
|
94
|
+
Chef::Log.warn("Failed to remove rvm_ruby[#{rubie}]. " +
|
95
|
+
"Check logs in #{RVM.path}/log/#{rubie}")
|
96
|
+
end
|
97
|
+
else
|
98
|
+
Chef::Log.debug("rvm_ruby[#{rubie}] was not installed, so skipping")
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
#
|
2
|
+
# Cookbook Name:: rvm
|
3
|
+
# Provider:: shell
|
4
|
+
#
|
5
|
+
# Author:: Fletcher Nichol <fnichol@nichol.ca>
|
6
|
+
#
|
7
|
+
# Copyright 2011, Fletcher Nichol
|
8
|
+
#
|
9
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
10
|
+
# you may not use this file except in compliance with the License.
|
11
|
+
# You may obtain a copy of the License at
|
12
|
+
#
|
13
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
14
|
+
#
|
15
|
+
# Unless required by applicable law or agreed to in writing, software
|
16
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
17
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
18
|
+
# See the License for the specific language governing permissions and
|
19
|
+
# limitations under the License.
|
20
|
+
#
|
21
|
+
|
22
|
+
action :run do
|
23
|
+
ruby_string = normalize_ruby_string(new_resource.ruby_string)
|
24
|
+
|
25
|
+
if env_exists?(ruby_string)
|
26
|
+
script_wrapper :run
|
27
|
+
else
|
28
|
+
Chef::Log.warn("rvm_environment[#{ruby_string}] not created, so skipping")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
##
|
34
|
+
# Wraps the script resource for RVM-dependent code.
|
35
|
+
#
|
36
|
+
# @param [Symbol] action to be performed with gem_package provider
|
37
|
+
# @param [optional, String, #to_s] the fully qualifed rvm string
|
38
|
+
def script_wrapper(exec_action, ruby_string=new_resource.ruby_string)
|
39
|
+
profile = find_profile_to_source
|
40
|
+
|
41
|
+
script_code = <<-CODE
|
42
|
+
if [ -s "${HOME}/.rvm/scripts/rvm" ]; then
|
43
|
+
source "${HOME}/.rvm/scripts/rvm"
|
44
|
+
elif [ -s "#{profile}" ]; then
|
45
|
+
source "#{profile}"
|
46
|
+
fi
|
47
|
+
|
48
|
+
rvm use #{ruby_string}
|
49
|
+
|
50
|
+
#{new_resource.code}
|
51
|
+
CODE
|
52
|
+
|
53
|
+
s = script new_resource.name do
|
54
|
+
interpreter "bash"
|
55
|
+
code script_code
|
56
|
+
creates new_resource.creates if new_resource.creates
|
57
|
+
cwd new_resource.cwd if new_resource.cwd
|
58
|
+
environment new_resource.environment if new_resource.environment
|
59
|
+
group new_resource.group if new_resource.group
|
60
|
+
path new_resource.path if new_resource.path
|
61
|
+
returns new_resource.returns if new_resource.returns
|
62
|
+
timeout new_resource.timeout if new_resource.timeout
|
63
|
+
user new_resource.user if new_resource.user
|
64
|
+
umask new_resource.umask if new_resource.umask
|
65
|
+
action :nothing
|
66
|
+
end
|
67
|
+
s.run_action(exec_action)
|
68
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
#
|
2
|
+
# Cookbook Name:: rvm
|
3
|
+
# Provider:: wrapper
|
4
|
+
#
|
5
|
+
# Author:: Fletcher Nichol <fnichol@nichol.ca>
|
6
|
+
#
|
7
|
+
# Copyright 2011, Fletcher Nichol
|
8
|
+
#
|
9
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
10
|
+
# you may not use this file except in compliance with the License.
|
11
|
+
# You may obtain a copy of the License at
|
12
|
+
#
|
13
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
14
|
+
#
|
15
|
+
# Unless required by applicable law or agreed to in writing, software
|
16
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
17
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
18
|
+
# See the License for the specific language governing permissions and
|
19
|
+
# limitations under the License.
|
20
|
+
#
|
21
|
+
|
22
|
+
action :create do
|
23
|
+
ruby_string = normalize_ruby_string(new_resource.ruby_string)
|
24
|
+
if new_resource.binary.nil?
|
25
|
+
binaries = new_resource.binaries || []
|
26
|
+
else
|
27
|
+
binaries = [ new_resource.binary ] || []
|
28
|
+
end
|
29
|
+
|
30
|
+
# ensure ruby is installed and gemset exists
|
31
|
+
unless env_exists?(ruby_string)
|
32
|
+
e = rvm_environment ruby_string do
|
33
|
+
action :nothing
|
34
|
+
end
|
35
|
+
e.run_action(:create)
|
36
|
+
end
|
37
|
+
|
38
|
+
env = RVM::Environment.new
|
39
|
+
env.use ruby_string
|
40
|
+
|
41
|
+
binaries.each do |b|
|
42
|
+
full_bin = "#{new_resource.prefix}_#{b}"
|
43
|
+
resource_name = "rvm_wrapper[#{full_bin}::#{ruby_string}]"
|
44
|
+
script = ::File.join(::File.dirname(node['rvm']['root_path']), "bin", full_bin)
|
45
|
+
|
46
|
+
if ::File.exists?(script)
|
47
|
+
Chef::Log.debug("#{resource_name} already exists, so updating")
|
48
|
+
else
|
49
|
+
Chef::Log.info("Creating #{resource_name}")
|
50
|
+
end
|
51
|
+
|
52
|
+
if env.wrapper ruby_string, new_resource.prefix, b
|
53
|
+
Chef::Log.debug("Creation/Update of #{resource_name} was successful.")
|
54
|
+
else
|
55
|
+
Chef::Log.warn("Failed to create/update #{resource_name}.")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
#
|
2
|
+
# Cookbook Name:: rvm
|
3
|
+
# Recipe:: default
|
4
|
+
#
|
5
|
+
# Copyright 2010, 2011, Fletcher Nichol
|
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
|
+
require 'rubygems/dependency_installer'
|
21
|
+
|
22
|
+
# install rvm api gem during chef compile phase
|
23
|
+
if Gem.source_index.find_name("rvm").empty?
|
24
|
+
Chef::Log.info("Installing RVM gem")
|
25
|
+
Gem::DependencyInstaller.new.install("rvm")
|
26
|
+
begin
|
27
|
+
Gem.activate("rvm")
|
28
|
+
require 'rvm'
|
29
|
+
rescue LoadError
|
30
|
+
Chef::Application.fatal!(
|
31
|
+
"There was a problem installing and loading the 'rvm' gem.")
|
32
|
+
end
|
33
|
+
else
|
34
|
+
Chef::Log.debug("RVM gem was installed, so installation skipped")
|
35
|
+
end
|
36
|
+
|
37
|
+
include_recipe "rvm::system" if node['rvm']['user'] == 'root'
|
38
|
+
include_recipe "rvm::user" unless node['rvm']['user'] == 'root'
|
39
|
+
|
40
|
+
if node['rvm']['install_rubies'] == true || node['rvm']['install_rubies'] == "true"
|
41
|
+
# set a default ruby
|
42
|
+
rvm_default_ruby node['rvm']['default_ruby']
|
43
|
+
|
44
|
+
# install additional rubies
|
45
|
+
node['rvm']['rubies'].each do |rubie|
|
46
|
+
rvm_ruby rubie
|
47
|
+
end
|
48
|
+
|
49
|
+
# install global gems
|
50
|
+
node['rvm']['global_gems'].each do |gem|
|
51
|
+
rvm_global_gem gem[:name] do
|
52
|
+
version gem[:version] if gem[:version]
|
53
|
+
action gem[:action] if gem[:action]
|
54
|
+
options gem[:options] if gem[:options]
|
55
|
+
source gem[:source] if gem[:source]
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# install additional gems
|
60
|
+
node['rvm']['gems'].each_pair do |rstring, gems|
|
61
|
+
rvm_environment rstring
|
62
|
+
|
63
|
+
gems.each do |gem|
|
64
|
+
rvm_gem gem[:name] do
|
65
|
+
ruby_string rstring
|
66
|
+
version gem[:version] if gem[:version]
|
67
|
+
action gem[:action] if gem[:action]
|
68
|
+
options gem[:options] if gem[:options]
|
69
|
+
source gem[:source] if gem[:source]
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#
|
2
|
+
# Cookbook Name:: rvm
|
3
|
+
# Recipe:: gem_package
|
4
|
+
#
|
5
|
+
# Copyright 2011, Fletcher Nichol
|
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
|
+
patch_gem_package
|
21
|
+
::Chef::Log.info "gem_package resource has been patched to use provider " <<
|
22
|
+
"Chef::Provider::Package::RVMRubygems and will install gems to " <<
|
23
|
+
"the #{node['rvm']['gem_package']['rvm_string']} RVM Ruby."
|
@@ -0,0 +1,69 @@
|
|
1
|
+
#
|
2
|
+
# Cookbook Name:: rvm
|
3
|
+
# Recipe:: system
|
4
|
+
#
|
5
|
+
# Copyright 2010, 2011 Fletcher Nichol
|
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
|
+
# thanks to:
|
21
|
+
# - http://www.agileweboperations.com/chef-rvm-ruby-enterprise-edition-as-default-ruby/
|
22
|
+
# - http://github.com/denimboy/xprdev/blob/master/rvm/recipes/default.rb
|
23
|
+
|
24
|
+
script_flags = ""
|
25
|
+
if node['rvm']['version']
|
26
|
+
script_flags += " --version #{node['rvm']['version']}"
|
27
|
+
end
|
28
|
+
if node['rvm']['branch']
|
29
|
+
script_flags += " --branch #{node['rvm']['branch']}"
|
30
|
+
end
|
31
|
+
|
32
|
+
upgrade_strategy = if node['rvm']['upgrade'].nil? || node['rvm']['upgrade'] == false
|
33
|
+
"none"
|
34
|
+
else
|
35
|
+
node['rvm']['upgrade']
|
36
|
+
end
|
37
|
+
|
38
|
+
pkgs = %w{ sed grep tar gzip bzip2 bash curl }
|
39
|
+
case node[:platform]
|
40
|
+
when "centos","redhat","fedora"
|
41
|
+
pkgs << "git"
|
42
|
+
when "debian","ubuntu","suse"
|
43
|
+
pkgs << "git-core"
|
44
|
+
end
|
45
|
+
|
46
|
+
pkgs.each do |pkg|
|
47
|
+
package pkg
|
48
|
+
end
|
49
|
+
|
50
|
+
execute "install system-wide RVM" do
|
51
|
+
user "root"
|
52
|
+
command <<-CODE
|
53
|
+
bash -c "bash <( curl -Ls #{node['rvm']['installer_url']} )#{script_flags}"
|
54
|
+
CODE
|
55
|
+
not_if rvm_wrap_cmd(%{type rvm | head -1 | grep -q '^rvm is a function$'})
|
56
|
+
end
|
57
|
+
|
58
|
+
template "/etc/rvmrc" do
|
59
|
+
source "rvmrc.erb"
|
60
|
+
owner "root"
|
61
|
+
group "rvm"
|
62
|
+
mode "0644"
|
63
|
+
end
|
64
|
+
|
65
|
+
execute "upgrade RVM to #{upgrade_strategy}" do
|
66
|
+
user "root"
|
67
|
+
command rvm_wrap_cmd(%{rvm get #{upgrade_strategy}})
|
68
|
+
only_if { %w{ latest head }.include? upgrade_strategy }
|
69
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
#
|
2
|
+
# Cookbook Name:: rvm
|
3
|
+
# Recipe:: system
|
4
|
+
#
|
5
|
+
|
6
|
+
script_flags = ""
|
7
|
+
if node['rvm']['version']
|
8
|
+
script_flags += " --version #{node['rvm']['version']}"
|
9
|
+
end
|
10
|
+
if node['rvm']['branch']
|
11
|
+
script_flags += " --branch #{node['rvm']['branch']}"
|
12
|
+
end
|
13
|
+
|
14
|
+
upgrade_strategy = if node['rvm']['upgrade'].nil? || node['rvm']['upgrade'] == false
|
15
|
+
"none"
|
16
|
+
else
|
17
|
+
node['rvm']['upgrade']
|
18
|
+
end
|
19
|
+
|
20
|
+
script "install user RVM" do
|
21
|
+
interpreter "bash"
|
22
|
+
code <<-CODE
|
23
|
+
source ~/.bash_profile
|
24
|
+
`type rvm | head -1 | grep -q '^rvm is a function$'`
|
25
|
+
if [ $? -ne 0 ]; then
|
26
|
+
bash -c "bash <( curl -s #{node['rvm']['installer_url']} )#{script_flags}"
|
27
|
+
fi
|
28
|
+
CODE
|
29
|
+
not_if rvm_wrap_cmd(%{type rvm | head -1 | grep -q '^rvm is a function$'})
|
30
|
+
end
|
31
|
+
|
32
|
+
execute "setup rvm script sourcing in ~/.bash_profile" do
|
33
|
+
command "echo '[[ -s \"$HOME/.rvm/scripts/rvm\" ]] && . \"$HOME/.rvm/scripts/rvm\" # Load RVM function' >> ~/.bash_profile"
|
34
|
+
not_if "grep -q '/.rvm/scripts/rvm' ~/.bash_profile"
|
35
|
+
end
|
36
|
+
|
37
|
+
template "#{ENV['HOME']}/.rvmrc" do
|
38
|
+
mode 0700
|
39
|
+
owner ENV['USER']
|
40
|
+
group Etc.getgrgid(Process.gid).name
|
41
|
+
source "rvmrc.erb"
|
42
|
+
end
|
43
|
+
|
44
|
+
execute "upgrade RVM to #{upgrade_strategy}" do
|
45
|
+
command rvm_wrap_cmd(%{rvm get #{upgrade_strategy}})
|
46
|
+
only_if { %w{ latest head }.include? upgrade_strategy }
|
47
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#
|
2
|
+
# Cookbook Name:: rvm
|
3
|
+
# Recipe:: vagrant
|
4
|
+
#
|
5
|
+
# Copyright 2011, Fletcher Nichol
|
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
|
+
template "/usr/local/bin/chef-solo" do
|
21
|
+
source "vagrant-chef-solo-wrapper.erb"
|
22
|
+
owner "root"
|
23
|
+
group "root"
|
24
|
+
mode "0755"
|
25
|
+
end
|
26
|
+
|
27
|
+
group "rvm" do
|
28
|
+
members ["vagrant"]
|
29
|
+
append true
|
30
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#
|
2
|
+
# Cookbook Name:: rvm
|
3
|
+
# Resource:: default_ruby
|
4
|
+
#
|
5
|
+
# Author:: Fletcher Nichol <fnichol@nichol.ca>
|
6
|
+
#
|
7
|
+
# Copyright 2011, Fletcher Nichol
|
8
|
+
#
|
9
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
10
|
+
# you may not use this file except in compliance with the License.
|
11
|
+
# You may obtain a copy of the License at
|
12
|
+
#
|
13
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
14
|
+
#
|
15
|
+
# Unless required by applicable law or agreed to in writing, software
|
16
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
17
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
18
|
+
# See the License for the specific language governing permissions and
|
19
|
+
# limitations under the License.
|
20
|
+
#
|
21
|
+
|
22
|
+
actions :create
|
23
|
+
|
24
|
+
attribute :ruby_string, :kind_of => String, :name_attribute => true
|
25
|
+
|
26
|
+
def initialize(*args)
|
27
|
+
super
|
28
|
+
@action = :create
|
29
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#
|
2
|
+
# Cookbook Name:: rvm
|
3
|
+
# Resource:: environment
|
4
|
+
#
|
5
|
+
# Author:: Fletcher Nichol <fnichol@nichol.ca>
|
6
|
+
#
|
7
|
+
# Copyright 2011, Fletcher Nichol
|
8
|
+
#
|
9
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
10
|
+
# you may not use this file except in compliance with the License.
|
11
|
+
# You may obtain a copy of the License at
|
12
|
+
#
|
13
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
14
|
+
#
|
15
|
+
# Unless required by applicable law or agreed to in writing, software
|
16
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
17
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
18
|
+
# See the License for the specific language governing permissions and
|
19
|
+
# limitations under the License.
|
20
|
+
#
|
21
|
+
|
22
|
+
actions :create
|
23
|
+
|
24
|
+
attribute :ruby_string, :kind_of => String, :name_attribute => true
|
25
|
+
|
26
|
+
def initialize(*args)
|
27
|
+
super
|
28
|
+
@action = :create
|
29
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#
|
2
|
+
# Cookbook Name:: rvm
|
3
|
+
# Resource:: gem
|
4
|
+
#
|
5
|
+
# Author:: Fletcher Nichol <fnichol@nichol.ca>
|
6
|
+
#
|
7
|
+
# Copyright 2011, Fletcher Nichol
|
8
|
+
#
|
9
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
10
|
+
# you may not use this file except in compliance with the License.
|
11
|
+
# You may obtain a copy of the License at
|
12
|
+
#
|
13
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
14
|
+
#
|
15
|
+
# Unless required by applicable law or agreed to in writing, software
|
16
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
17
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
18
|
+
# See the License for the specific language governing permissions and
|
19
|
+
# limitations under the License.
|
20
|
+
#
|
21
|
+
|
22
|
+
actions :install, :upgrade, :remove, :purge
|
23
|
+
|
24
|
+
attribute :package_name, :kind_of => String, :name_attribute => true
|
25
|
+
attribute :version, :kind_of => String
|
26
|
+
attribute :ruby_string, :kind_of => String, :default => "default"
|
27
|
+
attribute :response_file, :kind_of => String
|
28
|
+
attribute :source, :kind_of => String
|
29
|
+
attribute :options, :kind_of => Hash
|
30
|
+
attribute :gem_binary, :kind_of => String
|
31
|
+
|
32
|
+
def initialize(*args)
|
33
|
+
super
|
34
|
+
@action = :install
|
35
|
+
@provider = Chef::Provider::Package::RVMRubygems
|
36
|
+
end
|