from-scratch 0.1.0
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.
- checksums.yaml +7 -0
- data/.chef/knife.rb +6 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Berksfile +17 -0
- data/Berksfile.lock +19 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +58 -0
- data/Rakefile +6 -0
- data/Thorfile +5 -0
- data/bin/scratchify +6 -0
- data/chefignore +101 -0
- data/cookbooks/chef_gem/CHANGELOG.md +24 -0
- data/cookbooks/chef_gem/README.md +38 -0
- data/cookbooks/chef_gem/libraries/chef_gem.rb +72 -0
- data/cookbooks/chef_gem/metadata.json +29 -0
- data/cookbooks/chef_gem/recipes/default.rb +0 -0
- data/cookbooks/java/.gitignore +21 -0
- data/cookbooks/java/.kitchen.docker.yml +15 -0
- data/cookbooks/java/.kitchen.yml +126 -0
- data/cookbooks/java/.travis.yml +6 -0
- data/cookbooks/java/Berksfile +10 -0
- data/cookbooks/java/CHANGELOG.md +398 -0
- data/cookbooks/java/CONTRIBUTING.md +12 -0
- data/cookbooks/java/Gemfile +15 -0
- data/cookbooks/java/ISSUES.md +43 -0
- data/cookbooks/java/LICENSE +201 -0
- data/cookbooks/java/README.md +402 -0
- data/cookbooks/java/Rakefile +60 -0
- data/cookbooks/java/TESTING.md +41 -0
- data/cookbooks/java/attributes/default.rb +146 -0
- data/cookbooks/java/libraries/helpers.rb +120 -0
- data/cookbooks/java/libraries/matchers.rb +5 -0
- data/cookbooks/java/metadata.json +69 -0
- data/cookbooks/java/providers/alternatives.rb +94 -0
- data/cookbooks/java/providers/ark.rb +255 -0
- data/cookbooks/java/recipes/default.rb +22 -0
- data/cookbooks/java/recipes/default_java_symlink.rb +19 -0
- data/cookbooks/java/recipes/homebrew.rb +3 -0
- data/cookbooks/java/recipes/ibm.rb +76 -0
- data/cookbooks/java/recipes/ibm_tar.rb +70 -0
- data/cookbooks/java/recipes/openjdk.rb +74 -0
- data/cookbooks/java/recipes/oracle.rb +74 -0
- data/cookbooks/java/recipes/oracle_i386.rb +73 -0
- data/cookbooks/java/recipes/oracle_jce.rb +75 -0
- data/cookbooks/java/recipes/oracle_rpm.rb +60 -0
- data/cookbooks/java/recipes/purge_packages.rb +20 -0
- data/cookbooks/java/recipes/set_attributes_from_version.rb +55 -0
- data/cookbooks/java/recipes/set_java_home.rb +44 -0
- data/cookbooks/java/recipes/windows.rb +82 -0
- data/cookbooks/java/resources/alternatives.rb +30 -0
- data/cookbooks/java/resources/ark.rb +58 -0
- data/cookbooks/java/templates/default/ibm_jdk.installer.properties.erb +3 -0
- data/cookbooks/java/templates/default/oracle.jinfo.erb +6 -0
- data/cookbooks/rvm/.foodcritic +1 -0
- data/cookbooks/rvm/.gitignore +7 -0
- data/cookbooks/rvm/.kitchen.yml +66 -0
- data/cookbooks/rvm/.travis.yml +9 -0
- data/cookbooks/rvm/Berksfile +10 -0
- data/cookbooks/rvm/CHANGELOG.md +253 -0
- data/cookbooks/rvm/CODE_OF_CONDUCT.md +12 -0
- data/cookbooks/rvm/CONTRIBUTING.md +26 -0
- data/cookbooks/rvm/Gemfile +20 -0
- data/cookbooks/rvm/Guardfile +12 -0
- data/cookbooks/rvm/README.md +1459 -0
- data/cookbooks/rvm/Rakefile +18 -0
- data/cookbooks/rvm/attributes/.gitkeep +0 -0
- data/cookbooks/rvm/attributes/default.rb +68 -0
- data/cookbooks/rvm/attributes/gem_package.rb +23 -0
- data/cookbooks/rvm/attributes/vagrant.rb +23 -0
- data/cookbooks/rvm/libraries/chef_rvm_environment_helpers.rb +55 -0
- data/cookbooks/rvm/libraries/chef_rvm_gemset_helpers.rb +67 -0
- data/cookbooks/rvm/libraries/chef_rvm_recipe_helpers.rb +80 -0
- data/cookbooks/rvm/libraries/chef_rvm_ruby_helpers.rb +95 -0
- data/cookbooks/rvm/libraries/chef_rvm_set_helpers.rb +16 -0
- data/cookbooks/rvm/libraries/chef_rvm_shell_helpers.rb +57 -0
- data/cookbooks/rvm/libraries/chef_rvm_string_cache.rb +104 -0
- data/cookbooks/rvm/libraries/chef_rvm_string_helpers.rb +61 -0
- data/cookbooks/rvm/libraries/chef_rvm_version_helpers.rb +45 -0
- data/cookbooks/rvm/libraries/gem_package_monkeypatch.rb +34 -0
- data/cookbooks/rvm/libraries/provider_rvm_installation.rb +185 -0
- data/cookbooks/rvm/libraries/resource_rvm_installation.rb +103 -0
- data/cookbooks/rvm/libraries/rvm_chef_user_environment.rb +55 -0
- data/cookbooks/rvm/libraries/rvm_rubygems_package.rb +189 -0
- data/cookbooks/rvm/libraries/rvm_shell_chef_wrapper.rb +99 -0
- data/cookbooks/rvm/metadata.json +51 -0
- data/cookbooks/rvm/providers/default_ruby.rb +63 -0
- data/cookbooks/rvm/providers/environment.rb +78 -0
- data/cookbooks/rvm/providers/gemset.rb +118 -0
- data/cookbooks/rvm/providers/global_gem.rb +97 -0
- data/cookbooks/rvm/providers/ruby.rb +178 -0
- data/cookbooks/rvm/providers/shell.rb +121 -0
- data/cookbooks/rvm/providers/wrapper.rb +73 -0
- data/cookbooks/rvm/recipes/.gitkeep +0 -0
- data/cookbooks/rvm/recipes/default.rb +40 -0
- data/cookbooks/rvm/recipes/gem_package.rb +33 -0
- data/cookbooks/rvm/recipes/system.rb +37 -0
- data/cookbooks/rvm/recipes/system_install.rb +42 -0
- data/cookbooks/rvm/recipes/user.rb +43 -0
- data/cookbooks/rvm/recipes/user_install.rb +58 -0
- data/cookbooks/rvm/recipes/vagrant.rb +37 -0
- data/cookbooks/rvm/resources/default_ruby.rb +31 -0
- data/cookbooks/rvm/resources/environment.rb +31 -0
- data/cookbooks/rvm/resources/gem.rb +37 -0
- data/cookbooks/rvm/resources/gemset.rb +32 -0
- data/cookbooks/rvm/resources/global_gem.rb +34 -0
- data/cookbooks/rvm/resources/ruby.rb +32 -0
- data/cookbooks/rvm/resources/shell.rb +41 -0
- data/cookbooks/rvm/resources/wrapper.rb +34 -0
- data/cookbooks/rvm/templates/default/rvmrc.erb +14 -0
- data/cookbooks/rvm/templates/default/vagrant-chef-client-wrapper.erb +23 -0
- data/cookbooks/rvm/templates/default/vagrant-chef-solo-wrapper.erb +23 -0
- data/cookbooks/rvm/test/integration/data_bags/users/virgil1.json +4 -0
- data/cookbooks/rvm/test/integration/data_bags/users/virgil2.json +4 -0
- data/cookbooks/rvm/test/integration/data_bags/users/wigglebottom.json +3 -0
- data/cookbooks/rvm/test/integration/installs/bats/version_pinning.bats +13 -0
- data/cookbooks/rvm/test/integration/rubies/bats/_common.bash +16 -0
- data/cookbooks/rvm/test/integration/rubies/bats/verify_1.9.3.bats +9 -0
- data/cookbooks/rvm/test/integration/rubies/bats/verify_jruby.bats +12 -0
- data/cookbooks/rvm/test/integration/rubies/bats/verify_patch_support.bats +19 -0
- data/cookbooks/rvm/test/integration/rubies/bats/verify_ree.bats +9 -0
- data/cookbooks/rvm/test/integration/rubies/bats/verify_rubygems_version_support.bats +15 -0
- data/cookbooks/rvm/test/integration/stock_system_and_user/bats/system.bats +45 -0
- data/cookbooks/rvm/test/unit/libraries/provider_rvm_installation_spec.rb +220 -0
- data/cookbooks/rvm/test/unit/libraries/resource_rvm_installation_spec.rb +139 -0
- data/cookbooks/rvm/test/unit/spec_helper.rb +23 -0
- data/cookbooks/scratchify/.chef/knife.rb +9 -0
- data/cookbooks/scratchify/Berksfile +16 -0
- data/cookbooks/scratchify/Berksfile.lock +19 -0
- data/cookbooks/scratchify/LICENSE.txt +21 -0
- data/cookbooks/scratchify/README.md +41 -0
- data/cookbooks/scratchify/Thorfile +5 -0
- data/cookbooks/scratchify/bin/console +14 -0
- data/cookbooks/scratchify/bin/scratchify +6 -0
- data/cookbooks/scratchify/bin/setup +7 -0
- data/cookbooks/scratchify/chefignore +101 -0
- data/cookbooks/scratchify/data_bags/users/deploy.json +6 -0
- data/cookbooks/scratchify/environments/.gitkeep +0 -0
- data/cookbooks/scratchify/from-scratch.gemspec +36 -0
- data/cookbooks/scratchify/lib/from/scratch.rb +31 -0
- data/cookbooks/scratchify/lib/from/scratch/interviewer.rb +35 -0
- data/cookbooks/scratchify/lib/from/scratch/version.rb +3 -0
- data/cookbooks/scratchify/metadata.json +36 -0
- data/cookbooks/scratchify/nodes/normfood.ru.json +75 -0
- data/cookbooks/scratchify/recipes/default.rb +0 -0
- data/cookbooks/scratchify/roles/.gitkeep +0 -0
- data/cookbooks/scratchify/spec/from/scratch_spec.rb +11 -0
- data/cookbooks/scratchify/spec/spec_helper.rb +2 -0
- data/cookbooks/user/.gitignore +5 -0
- data/cookbooks/user/.kitchen.yml +46 -0
- data/cookbooks/user/.travis.yml +4 -0
- data/cookbooks/user/Berksfile +7 -0
- data/cookbooks/user/CHANGELOG.md +101 -0
- data/cookbooks/user/Gemfile +14 -0
- data/cookbooks/user/README.md +447 -0
- data/cookbooks/user/Rakefile +21 -0
- data/cookbooks/user/attributes/default.rb +50 -0
- data/cookbooks/user/libraries/matchers.rb +26 -0
- data/cookbooks/user/metadata.json +46 -0
- data/cookbooks/user/providers/account.rb +212 -0
- data/cookbooks/user/recipes/data_bag.rb +59 -0
- data/cookbooks/user/recipes/default.rb +18 -0
- data/cookbooks/user/resources/account.rb +41 -0
- data/cookbooks/user/templates/default/authorized_keys.erb +7 -0
- data/from-scratch.gemspec +33 -0
- data/lib/from-scratch.rb +25 -0
- data/lib/from-scratch/version.rb +3 -0
- data/metadata.rb +15 -0
- data/recipes/default.rb +0 -0
- data/templates/node.json.erb +31 -0
- data/templates/user.json.erb +6 -0
- metadata +330 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Cookbook Name:: rvm
|
|
3
|
+
# Provider:: 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
|
+
include Chef::RVM::StringHelpers
|
|
23
|
+
include Chef::RVM::EnvironmentHelpers
|
|
24
|
+
|
|
25
|
+
def load_current_resource
|
|
26
|
+
@rubie = normalize_ruby_string(select_ruby(new_resource.ruby_string))
|
|
27
|
+
@gemset = select_gemset(new_resource.ruby_string)
|
|
28
|
+
@ruby_string = @gemset.nil? ? @rubie : "#{@rubie}@#{@gemset}"
|
|
29
|
+
@rvm_env = ::RVM::ChefUserEnvironment.new(new_resource.user)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
action :create do
|
|
33
|
+
next if skip_ruby?
|
|
34
|
+
|
|
35
|
+
# ensure ruby is installed and gemset exists (if specified)
|
|
36
|
+
unless env_exists?(@ruby_string)
|
|
37
|
+
e = rvm_environment @ruby_string do
|
|
38
|
+
user new_resource.user
|
|
39
|
+
action :nothing
|
|
40
|
+
end
|
|
41
|
+
e.run_action(:create)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
Chef::Log.info("Setting default ruby to rvm_ruby[#{@ruby_string}]")
|
|
45
|
+
@rvm_env.rvm :use, @ruby_string, :default => true
|
|
46
|
+
new_resource.updated_by_last_action(true)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
private
|
|
50
|
+
|
|
51
|
+
def skip_ruby?
|
|
52
|
+
if @rubie.nil?
|
|
53
|
+
Chef::Log.warn("#{self.class.name}: RVM ruby string `#{@rubie}' " +
|
|
54
|
+
"is not known. Use `rvm list known` to get a full list.")
|
|
55
|
+
true
|
|
56
|
+
elsif ruby_default?(@ruby_string)
|
|
57
|
+
Chef::Log.debug("#{self.class.name}: `#{@ruby_string}' is already default, " +
|
|
58
|
+
"so skipping")
|
|
59
|
+
true
|
|
60
|
+
else
|
|
61
|
+
false
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Cookbook Name:: rvm
|
|
3
|
+
# Provider:: 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
|
+
include Chef::RVM::StringHelpers
|
|
23
|
+
include Chef::RVM::RubyHelpers
|
|
24
|
+
include Chef::RVM::GemsetHelpers
|
|
25
|
+
|
|
26
|
+
def load_current_resource
|
|
27
|
+
@rubie = normalize_ruby_string(select_ruby(new_resource.ruby_string))
|
|
28
|
+
@gemset = select_gemset(new_resource.ruby_string)
|
|
29
|
+
@ruby_string = @gemset.nil? ? @rubie : "#{@rubie}@#{@gemset}"
|
|
30
|
+
@rvm_env = ::RVM::ChefUserEnvironment.new(new_resource.user)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
action :create do
|
|
34
|
+
next if skip_environment?
|
|
35
|
+
|
|
36
|
+
if @gemset
|
|
37
|
+
gemset_resource :create
|
|
38
|
+
else
|
|
39
|
+
ruby_resource :install
|
|
40
|
+
end
|
|
41
|
+
new_resource.updated_by_last_action(true)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
private
|
|
45
|
+
|
|
46
|
+
def skip_environment?
|
|
47
|
+
if @rubie.nil?
|
|
48
|
+
Chef::Log.warn("#{self.class.name}: RVM ruby string `#{@rubie}' " +
|
|
49
|
+
"is not known. Use `rvm list known` to get a full list.")
|
|
50
|
+
true
|
|
51
|
+
else
|
|
52
|
+
false
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def gemset_resource(exec_action)
|
|
57
|
+
# ensure gemset is created, if specified
|
|
58
|
+
unless gemset_exists?(:ruby => @rubie, :gemset => @gemset)
|
|
59
|
+
r = rvm_gemset @ruby_string do
|
|
60
|
+
user new_resource.user
|
|
61
|
+
action :nothing
|
|
62
|
+
end
|
|
63
|
+
r.run_action(exec_action)
|
|
64
|
+
new_resource.updated_by_last_action(true) if r.updated_by_last_action?
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def ruby_resource(exec_action)
|
|
69
|
+
# ensure ruby is installed
|
|
70
|
+
unless ruby_installed?(@rubie)
|
|
71
|
+
r = rvm_ruby @rubie do
|
|
72
|
+
user new_resource.user
|
|
73
|
+
action :nothing
|
|
74
|
+
end
|
|
75
|
+
r.run_action(exec_action)
|
|
76
|
+
new_resource.updated_by_last_action(true) if r.updated_by_last_action?
|
|
77
|
+
end
|
|
78
|
+
end
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Cookbook Name:: rvm
|
|
3
|
+
# Provider:: gemset
|
|
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
|
+
include Chef::RVM::StringHelpers
|
|
23
|
+
include Chef::RVM::RubyHelpers
|
|
24
|
+
include Chef::RVM::GemsetHelpers
|
|
25
|
+
|
|
26
|
+
def load_current_resource
|
|
27
|
+
if new_resource.ruby_string
|
|
28
|
+
@rubie = normalize_ruby_string(select_ruby(new_resource.ruby_string))
|
|
29
|
+
@gemset = new_resource.gemset
|
|
30
|
+
else
|
|
31
|
+
@rubie = normalize_ruby_string(select_ruby(new_resource.gemset))
|
|
32
|
+
@gemset = select_gemset(new_resource.gemset)
|
|
33
|
+
end
|
|
34
|
+
@ruby_string = "#{@rubie}@#{@gemset}"
|
|
35
|
+
@rvm_env = ::RVM::ChefUserEnvironment.new(new_resource.user)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
action :create do
|
|
39
|
+
unless ruby_installed?(@rubie)
|
|
40
|
+
r = rvm_ruby @rubie do
|
|
41
|
+
user new_resource.user
|
|
42
|
+
action :nothing
|
|
43
|
+
end
|
|
44
|
+
r.run_action(:install)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
if gemset_exists?(:ruby => @rubie, :gemset => @gemset)
|
|
48
|
+
Chef::Log.debug("rvm_gemset[#{@ruby_string}] already exists, so skipping")
|
|
49
|
+
else
|
|
50
|
+
Chef::Log.info("Creating rvm_gemset[#{@ruby_string}]")
|
|
51
|
+
|
|
52
|
+
@rvm_env.use @rubie
|
|
53
|
+
if @rvm_env.gemset_create @gemset
|
|
54
|
+
update_installed_gemsets(@rubie)
|
|
55
|
+
Chef::Log.debug("Creation of rvm_gemset[#{@ruby_string}] was successful.")
|
|
56
|
+
else
|
|
57
|
+
Chef::Log.warn("Failed to create rvm_gemset[#{@ruby_string}].")
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
new_resource.updated_by_last_action(true)
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
action :delete do
|
|
65
|
+
if gemset_exists?(:ruby => @rubie, :gemset => @gemset)
|
|
66
|
+
Chef::Log.info("Deleting rvm_gemset[#{@ruby_string}]")
|
|
67
|
+
|
|
68
|
+
@rvm_env.use @rubie
|
|
69
|
+
if @rvm_env.gemset_delete @gemset
|
|
70
|
+
update_installed_gemsets(@rubie)
|
|
71
|
+
Chef::Log.debug("Deletion of rvm_gemset[#{@ruby_string}] was successful.")
|
|
72
|
+
new_resource.updated_by_last_action(true)
|
|
73
|
+
else
|
|
74
|
+
Chef::Log.warn("Failed to delete rvm_gemset[#{@ruby_string}].")
|
|
75
|
+
end
|
|
76
|
+
else
|
|
77
|
+
Chef::Log.debug("rvm_gemset[#{@ruby_string}] does not exist, so skipping")
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
action :empty do
|
|
82
|
+
if gemset_exists?(:ruby => @rubie, :gemset => @gemset)
|
|
83
|
+
Chef::Log.info("Emptying rvm_gemset[#{@ruby_string}]")
|
|
84
|
+
|
|
85
|
+
@rvm_env.use @ruby_string
|
|
86
|
+
if @rvm_env.gemset_empty
|
|
87
|
+
update_installed_gemsets(@rubie)
|
|
88
|
+
Chef::Log.debug("Emptying of rvm_gemset[#{@ruby_string}] was successful.")
|
|
89
|
+
new_resource.updated_by_last_action(true)
|
|
90
|
+
else
|
|
91
|
+
Chef::Log.warn("Failed to empty rvm_gemset[#{@ruby_string}].")
|
|
92
|
+
end
|
|
93
|
+
else
|
|
94
|
+
Chef::Log.debug("rvm_gemset[#{@ruby_string}] does not exist, so skipping")
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
action :update do
|
|
99
|
+
Chef::Log.info("Updating rvm_gemset[#{@ruby_string}]")
|
|
100
|
+
|
|
101
|
+
# create gemset if it doesn't exist
|
|
102
|
+
unless gemset_exists?(:ruby => @rubie, :gemset => @gemset)
|
|
103
|
+
c = rvm_gemset @ruby_string do
|
|
104
|
+
user new_resource.user
|
|
105
|
+
action :nothing
|
|
106
|
+
end
|
|
107
|
+
c.run_action(:create)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
@rvm_env.use @ruby_string
|
|
111
|
+
if @rvm_env.gemset_update
|
|
112
|
+
update_installed_gemsets(@rubie)
|
|
113
|
+
Chef::Log.debug("Updating of rvm_gemset[#{@ruby_string}] was successful.")
|
|
114
|
+
new_resource.updated_by_last_action(true)
|
|
115
|
+
else
|
|
116
|
+
Chef::Log.warn("Failed to update rvm_gemset[#{@ruby_string}].")
|
|
117
|
+
end
|
|
118
|
+
end
|
|
@@ -0,0 +1,97 @@
|
|
|
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
|
+
include Chef::RVM::RubyHelpers
|
|
23
|
+
|
|
24
|
+
def load_current_resource
|
|
25
|
+
@rvm_env = ::RVM::ChefUserEnvironment.new(new_resource.user)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
[:install, :upgrade, :remove, :purge].each do |exec_action|
|
|
29
|
+
action exec_action do
|
|
30
|
+
# add gem entry into global.gems
|
|
31
|
+
update_global_gems_file exec_action
|
|
32
|
+
|
|
33
|
+
# install gem in all rubies in global gemsets
|
|
34
|
+
installed_rubies.each do |rubie|
|
|
35
|
+
gem_package_wrapper exec_action, "#{rubie}@global"
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
private
|
|
41
|
+
|
|
42
|
+
##
|
|
43
|
+
# Wraps the rvm_gem resource
|
|
44
|
+
#
|
|
45
|
+
# @param [Symbol] action to be performed with gem_package provider
|
|
46
|
+
# @param [optional, String, #to_s] the fully qualifed rvm string
|
|
47
|
+
def gem_package_wrapper(exec_action, ruby_global_gemset)
|
|
48
|
+
g = rvm_gem new_resource.package_name do
|
|
49
|
+
ruby_string ruby_global_gemset
|
|
50
|
+
source new_resource.source if new_resource.source
|
|
51
|
+
options new_resource.options if new_resource.options
|
|
52
|
+
version new_resource.version if new_resource.version
|
|
53
|
+
gem_binary new_resource.gem_binary if new_resource.gem_binary
|
|
54
|
+
user new_resource.user
|
|
55
|
+
action :nothing
|
|
56
|
+
end
|
|
57
|
+
g.run_action(exec_action)
|
|
58
|
+
new_resource.updated_by_last_action(true) if g.updated_by_last_action?
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
##
|
|
62
|
+
# Updates global.gems file to create or remove a gem entry
|
|
63
|
+
#
|
|
64
|
+
# @oaram [Symbol] action to :create or :remove the gem from the file
|
|
65
|
+
def update_global_gems_file(exec_action)
|
|
66
|
+
gem = if new_resource.version
|
|
67
|
+
"#{new_resource.package_name} -v#{new_resource.version}"
|
|
68
|
+
else
|
|
69
|
+
new_resource.package_name
|
|
70
|
+
end
|
|
71
|
+
user_dir = Etc.getpwnam(new_resource.user).dir if new_resource.user
|
|
72
|
+
global_gems_file = if new_resource.user
|
|
73
|
+
"#{user_dir}/.rvm/gemsets/global.gems"
|
|
74
|
+
else
|
|
75
|
+
"#{node['rvm']['root_path']}/gemsets/global.gems"
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
if [:install, :upgrade].include?(exec_action)
|
|
79
|
+
e = execute "Add #{gem} to #{global_gems_file}" do
|
|
80
|
+
if new_resource.user
|
|
81
|
+
user new_resource.user
|
|
82
|
+
group Etc.getpwnam(new_resource.user).gid
|
|
83
|
+
environment ({ 'USER' => new_resource.user, 'HOME' => user_dir })
|
|
84
|
+
else
|
|
85
|
+
user "root"
|
|
86
|
+
group "rvm"
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
command %{echo "#{gem}" >> "#{global_gems_file}"}
|
|
90
|
+
action :nothing
|
|
91
|
+
|
|
92
|
+
not_if %{grep -q "^#{gem}" "#{global_gems_file}"}
|
|
93
|
+
end
|
|
94
|
+
e.run_action(:run)
|
|
95
|
+
new_resource.updated_by_last_action(true) if e.updated_by_last_action?
|
|
96
|
+
end
|
|
97
|
+
end
|
|
@@ -0,0 +1,178 @@
|
|
|
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
|
+
include Chef::RVM::StringHelpers
|
|
23
|
+
include Chef::RVM::RubyHelpers
|
|
24
|
+
|
|
25
|
+
def load_current_resource
|
|
26
|
+
@rubie = normalize_ruby_string(select_ruby(new_resource.ruby_string))
|
|
27
|
+
@ruby_string = new_resource.ruby_string
|
|
28
|
+
@rvm_env = ::RVM::ChefUserEnvironment.new(
|
|
29
|
+
new_resource.user, "default",
|
|
30
|
+
:rvm_rubygems_version => new_resource.rubygems_version,
|
|
31
|
+
:source_environment => false
|
|
32
|
+
)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
action :install do
|
|
36
|
+
next if skip_ruby?
|
|
37
|
+
|
|
38
|
+
if ruby_installed?(@ruby_string)
|
|
39
|
+
Chef::Log.debug("rvm_ruby[#{@rubie}] is already installed, so skipping")
|
|
40
|
+
else
|
|
41
|
+
install_start = Time.now
|
|
42
|
+
install_options = {:rvm_by_path => true}
|
|
43
|
+
install_options[:patch] = new_resource.patch if new_resource.patch
|
|
44
|
+
|
|
45
|
+
install_ruby_dependencies @rubie
|
|
46
|
+
|
|
47
|
+
Chef::Log.info("Building rvm_ruby[#{@rubie}], this could take a while...")
|
|
48
|
+
|
|
49
|
+
if @rvm_env.install(@rubie, install_options)
|
|
50
|
+
Chef::Log.info("Installation of rvm_ruby[#{@rubie}] was successful.")
|
|
51
|
+
@rvm_env.use @rubie
|
|
52
|
+
update_installed_rubies
|
|
53
|
+
new_resource.updated_by_last_action(true)
|
|
54
|
+
|
|
55
|
+
Chef::Log.info("Importing initial gemsets for rvm_ruby[#{@rubie}]")
|
|
56
|
+
if @rvm_env.gemset_initial
|
|
57
|
+
Chef::Log.debug("Initial gemsets for rvm_ruby[#{@rubie}] are installed")
|
|
58
|
+
else
|
|
59
|
+
Chef::Log.warn(
|
|
60
|
+
"Failed to install initial gemsets for rvm_ruby[#{@rubie}] ")
|
|
61
|
+
end
|
|
62
|
+
else
|
|
63
|
+
Chef::Log.warn("Failed to install rvm_ruby[#{@rubie}]. " +
|
|
64
|
+
"Check logs in #{::RVM.path}/log/#{@rubie}")
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
Chef::Log.info("rvm_ruby[#{@rubie}] build time was " +
|
|
68
|
+
"#{(Time.now - install_start)/60.0} minutes.")
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
action :uninstall do
|
|
73
|
+
next if skip_ruby?
|
|
74
|
+
|
|
75
|
+
if ruby_installed?(@rubie)
|
|
76
|
+
Chef::Log.info("Uninstalling rvm_ruby[#{@rubie}]")
|
|
77
|
+
|
|
78
|
+
if @rvm_env.uninstall(@rubie, :rvm_by_path => true)
|
|
79
|
+
update_installed_rubies
|
|
80
|
+
Chef::Log.debug("Uninstallation of rvm_ruby[#{@rubie}] was successful.")
|
|
81
|
+
new_resource.updated_by_last_action(true)
|
|
82
|
+
else
|
|
83
|
+
Chef::Log.warn("Failed to uninstall rvm_ruby[#{@rubie}]. " +
|
|
84
|
+
"Check logs in #{::RVM.path}/log/#{@rubie}")
|
|
85
|
+
end
|
|
86
|
+
else
|
|
87
|
+
Chef::Log.debug("rvm_ruby[#{@rubie}] was not installed, so skipping")
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
action :remove do
|
|
92
|
+
next if skip_ruby?
|
|
93
|
+
|
|
94
|
+
if ruby_installed?(@rubie)
|
|
95
|
+
Chef::Log.info("Removing rvm_ruby[#{@rubie}]")
|
|
96
|
+
|
|
97
|
+
if @rvm_env.remove(@rubie, :rvm_by_path => true)
|
|
98
|
+
update_installed_rubies
|
|
99
|
+
Chef::Log.debug("Removal of rvm_ruby[#{@rubie}] was successful.")
|
|
100
|
+
new_resource.updated_by_last_action(true)
|
|
101
|
+
else
|
|
102
|
+
Chef::Log.warn("Failed to remove rvm_ruby[#{@rubie}]. " +
|
|
103
|
+
"Check logs in #{::RVM.path}/log/#{@rubie}")
|
|
104
|
+
end
|
|
105
|
+
else
|
|
106
|
+
Chef::Log.debug("rvm_ruby[#{@rubie}] was not installed, so skipping")
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
private
|
|
111
|
+
|
|
112
|
+
def skip_ruby?
|
|
113
|
+
if @rubie.nil?
|
|
114
|
+
Chef::Log.warn("#{self.class.name}: RVM ruby string `#{@rubie}' " +
|
|
115
|
+
"is not known. Use `rvm list known` to get a full list.")
|
|
116
|
+
true
|
|
117
|
+
else
|
|
118
|
+
false
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
##
|
|
123
|
+
# Installs any package dependencies needed by a given ruby
|
|
124
|
+
#
|
|
125
|
+
# @param [String, #to_s] the fully qualified RVM ruby string
|
|
126
|
+
def install_ruby_dependencies(rubie)
|
|
127
|
+
pkgs = []
|
|
128
|
+
case rubie
|
|
129
|
+
when /^ruby-/, /^ree-/, /^rbx-/, /^kiji/
|
|
130
|
+
case node['platform']
|
|
131
|
+
when "debian","ubuntu"
|
|
132
|
+
pkgs = %w{ build-essential openssl libreadline6 libreadline6-dev
|
|
133
|
+
zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev
|
|
134
|
+
sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev
|
|
135
|
+
ncurses-dev automake libtool bison ssl-cert pkg-config libgdbm-dev libffi-dev}
|
|
136
|
+
pkgs += %w{ subversion } if rubie =~ /^ruby-head$/
|
|
137
|
+
when "suse"
|
|
138
|
+
pkgs = %w{ gcc-c++ patch zlib zlib-devel libffi-devel
|
|
139
|
+
sqlite3-devel libxml2-devel libxslt-devel }
|
|
140
|
+
if node['platform_version'].to_f >= 11.0
|
|
141
|
+
pkgs += %w{ libreadline5 readline-devel libopenssl-devel }
|
|
142
|
+
else
|
|
143
|
+
pkgs += %w{ readline readline-devel openssl-devel }
|
|
144
|
+
end
|
|
145
|
+
pkgs += %w{ git subversion autoconf } if rubie =~ /^ruby-head$/
|
|
146
|
+
when "centos","redhat","fedora","scientific","amazon"
|
|
147
|
+
pkgs = %w{ gcc-c++ patch readline readline-devel zlib zlib-devel
|
|
148
|
+
libyaml-devel libffi-devel openssl-devel
|
|
149
|
+
make bzip2 autoconf automake libtool bison
|
|
150
|
+
libxml2 libxml2-devel libxslt libxslt-devel }
|
|
151
|
+
pkgs += %w{ git subversion autoconf } if rubie =~ /^ruby-head$/
|
|
152
|
+
when "gentoo"
|
|
153
|
+
pkgs = %w{ libiconv readline zlib openssl libyaml sqlite libxslt libtool gcc autoconf automake bison m4 }
|
|
154
|
+
end
|
|
155
|
+
when /^jruby/
|
|
156
|
+
begin
|
|
157
|
+
resource_collection.find("ruby_block[update-java-alternatives]").
|
|
158
|
+
run_action(:create)
|
|
159
|
+
rescue Chef::Exceptions::ResourceNotFound
|
|
160
|
+
Chef::Log.debug(
|
|
161
|
+
"java cookbook not loaded or not on ubuntu/debian, so skipping")
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
# TODO: need to figure out how to pull in java recipe only when needed. For
|
|
165
|
+
# now, users of jruby will have to add the "java" recipe to their run_list.
|
|
166
|
+
#include_recipe "java"
|
|
167
|
+
case node['platform']
|
|
168
|
+
when "debian","ubuntu"
|
|
169
|
+
pkgs += %w{ g++ ant }
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
pkgs.each do |pkg|
|
|
174
|
+
package pkg do
|
|
175
|
+
action :nothing
|
|
176
|
+
end.run_action(:install)
|
|
177
|
+
end
|
|
178
|
+
end
|