from-scratch 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,103 @@
|
|
1
|
+
#
|
2
|
+
# Cookbook Name:: rvm
|
3
|
+
# Resource:: rvm_installation
|
4
|
+
#
|
5
|
+
# Author:: Fletcher Nichol <fnichol@nichol.ca>
|
6
|
+
#
|
7
|
+
# Copyright 2013, 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
|
+
require "chef/resource"
|
23
|
+
|
24
|
+
class Chef
|
25
|
+
|
26
|
+
class Resource
|
27
|
+
|
28
|
+
class RvmInstallation < Chef::Resource
|
29
|
+
|
30
|
+
state_attrs :installed, :version
|
31
|
+
|
32
|
+
def initialize(name, run_context = nil)
|
33
|
+
super
|
34
|
+
|
35
|
+
@action = :install
|
36
|
+
@allowed_actions.push(:install, :force)
|
37
|
+
@resource_name = :rvm_installation
|
38
|
+
@user = name
|
39
|
+
@provider = Chef::Provider::RvmInstallation
|
40
|
+
|
41
|
+
node_attrs = rvm_node_attrs(run_context)
|
42
|
+
@installer_url = node_attrs["installer_url"]
|
43
|
+
@installer_flags = node_attrs["installer_flags"]
|
44
|
+
@install_pkgs = node_attrs["install_pkgs"]
|
45
|
+
@rvmrc_template_source = "rvmrc.erb"
|
46
|
+
@rvmrc_template_cookbook = "rvm"
|
47
|
+
@rvmrc_gem_options = node_attrs["gem_options"]
|
48
|
+
@default_rvmrc_env = Mash.new(node_attrs["rvmrc_env"])
|
49
|
+
@rvmrc_env = node_attrs["rvmrc_env"]
|
50
|
+
@installed = false
|
51
|
+
@version = nil
|
52
|
+
end
|
53
|
+
|
54
|
+
def user(arg = nil)
|
55
|
+
set_or_return(:user, arg, :kind_of => [String])
|
56
|
+
end
|
57
|
+
|
58
|
+
def installer_url(arg = nil)
|
59
|
+
set_or_return(:installer_url, arg, :kind_of => [String])
|
60
|
+
end
|
61
|
+
|
62
|
+
def installer_flags(arg = nil)
|
63
|
+
set_or_return(:installer_flags, arg, :kind_of => [String])
|
64
|
+
end
|
65
|
+
|
66
|
+
def install_pkgs(arg = nil)
|
67
|
+
set_or_return(:install_pkgs, arg, :kind_of => [String])
|
68
|
+
end
|
69
|
+
|
70
|
+
def rvmrc_template_source(arg = nil)
|
71
|
+
set_or_return(:rvmrc_template_source, arg, :kind_of => [String])
|
72
|
+
end
|
73
|
+
|
74
|
+
def rvmrc_template_cookbook(arg = nil)
|
75
|
+
set_or_return(:rvmrc_template_cookbook, arg, :kind_of => [String])
|
76
|
+
end
|
77
|
+
|
78
|
+
def rvmrc_gem_options(arg = nil)
|
79
|
+
set_or_return(:rvmrc_gem_options, arg, :kind_of => [String])
|
80
|
+
end
|
81
|
+
|
82
|
+
def rvmrc_env(arg = nil)
|
83
|
+
val = arg.nil? ? nil : @default_rvmrc_env.merge(Mash.new(arg))
|
84
|
+
set_or_return(:rvmrc_env, val, :kind_of => [Hash])
|
85
|
+
end
|
86
|
+
|
87
|
+
def installed(arg = nil)
|
88
|
+
set_or_return(:installed, arg, :kind_of => [TrueClass, FalseClass])
|
89
|
+
end
|
90
|
+
|
91
|
+
def version(arg = nil)
|
92
|
+
set_or_return(:version, arg, :kind_of => [String])
|
93
|
+
end
|
94
|
+
|
95
|
+
private
|
96
|
+
|
97
|
+
def rvm_node_attrs(run_context)
|
98
|
+
attrs = run_context && run_context.node && run_context.node["rvm"]
|
99
|
+
attrs || Mash.new
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
#
|
2
|
+
# Cookbook Name:: rvm
|
3
|
+
# Library:: RVM::ChefUserEnvironment
|
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
|
+
def create_rvm_chef_user_environment
|
23
|
+
klass = Class.new(::RVM::Environment) do
|
24
|
+
attr_reader :user, :source_environment
|
25
|
+
|
26
|
+
def initialize(user = nil, environment_name = "default", options = {})
|
27
|
+
@source_environment = options.delete(:source_environment)
|
28
|
+
@source_environment = true if @source_environment.nil?
|
29
|
+
@user = user
|
30
|
+
# explicitly set rvm_path if user is set
|
31
|
+
if @user.nil?
|
32
|
+
config['rvm_path'] = @@root_rvm_path
|
33
|
+
else
|
34
|
+
config['rvm_path'] = File.join(Etc.getpwnam(@user).dir, '.rvm')
|
35
|
+
end
|
36
|
+
|
37
|
+
merge_config! options
|
38
|
+
@environment_name = environment_name
|
39
|
+
@shell_wrapper = ::RVM::Shell::ChefWrapper.new(@user)
|
40
|
+
@shell_wrapper.setup do |s|
|
41
|
+
if source_environment
|
42
|
+
source_rvm_environment
|
43
|
+
use_rvm_environment
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.root_rvm_path=(path)
|
49
|
+
@@root_rvm_path = path
|
50
|
+
end
|
51
|
+
end
|
52
|
+
::RVM.const_set('ChefUserEnvironment', klass)
|
53
|
+
|
54
|
+
::RVM::ChefUserEnvironment.root_rvm_path = node['rvm']['root_path']
|
55
|
+
end
|
@@ -0,0 +1,189 @@
|
|
1
|
+
#
|
2
|
+
# Cookbook Name:: rvm
|
3
|
+
# Provider:: Chef::Provider::Package::RVMRubygems
|
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
|
+
class Chef
|
23
|
+
module RVM
|
24
|
+
module ShellHelpers
|
25
|
+
# stub to satisfy RVMRubygems (library load order not guarenteed)
|
26
|
+
end
|
27
|
+
module SetHelpers
|
28
|
+
# stub to satisfy RVMRubygems (library load order not guarenteed)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class Provider
|
33
|
+
class Package
|
34
|
+
class RVMRubygems < Chef::Provider::Package::Rubygems
|
35
|
+
include Chef::RVM::ShellHelpers
|
36
|
+
include Chef::RVM::SetHelpers
|
37
|
+
|
38
|
+
class RVMGemEnvironment < AlternateGemEnvironment
|
39
|
+
include Chef::RVM::ShellHelpers
|
40
|
+
include Chef::RVM::SetHelpers
|
41
|
+
|
42
|
+
attr_reader :ruby_strings, :user
|
43
|
+
|
44
|
+
def initialize(gem_binary_location, ruby_strings, user = nil)
|
45
|
+
super(gem_binary_location)
|
46
|
+
@ruby_strings = ruby_strings
|
47
|
+
@user = user
|
48
|
+
end
|
49
|
+
|
50
|
+
def gem_paths
|
51
|
+
cmd = "rvm #{ruby_strings.join(',')} "
|
52
|
+
cmd << "#{rvm_do(user)} #{@gem_binary_location} env gempath"
|
53
|
+
|
54
|
+
if user
|
55
|
+
user_dir = Etc.getpwnam(user).dir
|
56
|
+
environment = { 'USER' => user, 'HOME' => user_dir }
|
57
|
+
else
|
58
|
+
user_dir = nil
|
59
|
+
environment = nil
|
60
|
+
end
|
61
|
+
|
62
|
+
# shellout! is a fork/exec which won't work on windows
|
63
|
+
shell_style_paths = shell_out!(
|
64
|
+
rvm_wrap_cmd(cmd, user_dir), :env => environment).stdout
|
65
|
+
# on windows, the path separator is semicolon
|
66
|
+
paths = shell_style_paths.split(
|
67
|
+
::File::PATH_SEPARATOR).map { |path| path.strip }
|
68
|
+
end
|
69
|
+
|
70
|
+
def gem_platforms
|
71
|
+
cmd = "rvm #{ruby_strings.join(',')} "
|
72
|
+
cmd << "#{rvm_do(user)} #{@gem_binary_location} env"
|
73
|
+
|
74
|
+
if user
|
75
|
+
user_dir = Etc.getpwnam(user).dir
|
76
|
+
environment = { 'USER' => user, 'HOME' => user_dir }
|
77
|
+
else
|
78
|
+
user_dir = nil
|
79
|
+
environment = nil
|
80
|
+
end
|
81
|
+
|
82
|
+
gem_environment = shell_out!(
|
83
|
+
rvm_wrap_cmd(cmd, user_dir), :env => environment).stdout
|
84
|
+
if jruby = gem_environment[JRUBY_PLATFORM]
|
85
|
+
['ruby', Gem::Platform.new(jruby)]
|
86
|
+
else
|
87
|
+
Gem.platforms
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def initialize(new_resource, run_context=nil)
|
93
|
+
original_gem_binary = new_resource.gem_binary
|
94
|
+
super
|
95
|
+
new_resource.gem_binary("gem") unless original_gem_binary
|
96
|
+
user = new_resource.respond_to?("user") ? new_resource.user : nil
|
97
|
+
@gem_env = RVMGemEnvironment.new(gem_binary_path, ruby_strings, user)
|
98
|
+
end
|
99
|
+
|
100
|
+
##
|
101
|
+
# Determine the array of RVM ruby strings to use in this provider.
|
102
|
+
# In most cases only a single string value will be specified, but
|
103
|
+
# an array is always returned to account for multiple rubies.
|
104
|
+
#
|
105
|
+
# @return [Array] an array of RVM ruby strings
|
106
|
+
def ruby_strings
|
107
|
+
@ruby_strings ||= begin
|
108
|
+
result = if new_resource.respond_to?("ruby_string")
|
109
|
+
# the resource understands `.ruby_string' natively
|
110
|
+
new_resource.ruby_string
|
111
|
+
else
|
112
|
+
# most likely the gem_package resource or another native one
|
113
|
+
node['rvm']['gem_package']['rvm_string']
|
114
|
+
end
|
115
|
+
|
116
|
+
# if the result is a String, then wrap in an Array, otherwise
|
117
|
+
# return the array
|
118
|
+
case result
|
119
|
+
when String; [ result ]
|
120
|
+
when Array; result
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
def install_package(name, version)
|
126
|
+
# ensure each ruby is installed and gemset exists
|
127
|
+
ruby_strings.each do |rubie|
|
128
|
+
next if rubie == 'system'
|
129
|
+
e = ::Chef::Resource::RvmEnvironment.new(rubie, @run_context)
|
130
|
+
e.user(gem_env.user) if gem_env.user
|
131
|
+
e.action(:nothing)
|
132
|
+
e.run_action(:create)
|
133
|
+
end
|
134
|
+
|
135
|
+
install_via_gem_command(name, version)
|
136
|
+
true
|
137
|
+
end
|
138
|
+
|
139
|
+
def install_via_gem_command(name, version)
|
140
|
+
# Handle installing from a local file.
|
141
|
+
if source_is_remote?
|
142
|
+
src = @new_resource.source &&
|
143
|
+
" --source=#{@new_resource.source} --source=http://rubygems.org"
|
144
|
+
else
|
145
|
+
name = @new_resource.source
|
146
|
+
end
|
147
|
+
|
148
|
+
cmd = %{rvm #{ruby_strings.join(',')} #{rvm_do(gem_env.user)} #{gem_binary_path}}
|
149
|
+
cmd << %{ install #{name} -q --no-rdoc --no-ri -v "#{version}"}
|
150
|
+
cmd << %{#{src}#{opts}}
|
151
|
+
|
152
|
+
if gem_env.user
|
153
|
+
user_dir = Etc.getpwnam(gem_env.user).dir
|
154
|
+
environment = { 'USER' => gem_env.user, 'HOME' => user_dir }
|
155
|
+
else
|
156
|
+
user_dir = nil
|
157
|
+
environment = nil
|
158
|
+
end
|
159
|
+
|
160
|
+
shell_out!(rvm_wrap_cmd(cmd, user_dir), :env => environment)
|
161
|
+
end
|
162
|
+
|
163
|
+
def remove_package(name, version)
|
164
|
+
uninstall_via_gem_command(name, version)
|
165
|
+
end
|
166
|
+
|
167
|
+
def uninstall_via_gem_command(name, version)
|
168
|
+
cmd = %{rvm #{ruby_strings.join(',')} #{rvm_do(gem_env.user)} #{gem_binary_path}}
|
169
|
+
cmd << %{ uninstall #{name} -q -x -I}
|
170
|
+
if version
|
171
|
+
cmd << %{ -v "#{version}"#{opts}}
|
172
|
+
else
|
173
|
+
cmd << %{ -a#{opts}}
|
174
|
+
end
|
175
|
+
|
176
|
+
if gem_env.user
|
177
|
+
user_dir = Etc.getpwnam(gem_env.user).dir
|
178
|
+
environment = { 'USER' => gem_env.user, 'HOME' => user_dir }
|
179
|
+
else
|
180
|
+
user_dir = nil
|
181
|
+
environment = nil
|
182
|
+
end
|
183
|
+
|
184
|
+
shell_out!(rvm_wrap_cmd(cmd, user_dir), :env => environment)
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
#
|
2
|
+
# Cookbook Name:: rvm
|
3
|
+
# Library:: RVM::Shell::ChefWrapper
|
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
|
+
def create_rvm_shell_chef_wrapper
|
23
|
+
require 'chef/mixin/command'
|
24
|
+
|
25
|
+
klass = Class.new(::RVM::Shell::AbstractWrapper) do
|
26
|
+
include Chef::Mixin::Command
|
27
|
+
|
28
|
+
attr_accessor :current
|
29
|
+
|
30
|
+
def initialize(user = nil, sh = 'bash -l', &setup_block)
|
31
|
+
@user = user
|
32
|
+
super(sh, &setup_block)
|
33
|
+
end
|
34
|
+
|
35
|
+
# Runs a given command in the current shell.
|
36
|
+
# Defaults the command to true if empty.
|
37
|
+
def run_command(command)
|
38
|
+
command = "true" if command.to_s.strip.empty?
|
39
|
+
with_shell_instance do
|
40
|
+
Chef::Log.debug("RVM::Shell::ChefWrapper executing: " +
|
41
|
+
"[#{wrapped_command(command)}]")
|
42
|
+
stdin.puts wrapped_command(command)
|
43
|
+
stdin.close
|
44
|
+
out, err = stdout.read, stderr.read
|
45
|
+
out, status, _ = raw_stdout_to_parts(out)
|
46
|
+
return status, out, err
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# Runs a command, ensuring no output is collected.
|
51
|
+
def run_command_silently(command)
|
52
|
+
with_shell_instance do
|
53
|
+
Chef::Log.debug("RVM::Shell::ChefWrapper silently executing: " +
|
54
|
+
"[#{wrapped_command(command)}]")
|
55
|
+
stdin.puts silent_command(command)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
protected
|
60
|
+
|
61
|
+
# yields stdio, stderr and stdin for a shell instance.
|
62
|
+
# If there isn't a current shell instance, it will create a new one.
|
63
|
+
# In said scenario, it will also cleanup once it is done.
|
64
|
+
def with_shell_instance(&blk)
|
65
|
+
no_current = @current.nil?
|
66
|
+
if no_current
|
67
|
+
Chef::Log.debug("RVM::Shell::ChefWrapper subprocess executing with " +
|
68
|
+
"environment of: [#{shell_params.inspect}].")
|
69
|
+
@current = popen4(self.shell_executable, shell_params)
|
70
|
+
invoke_setup!
|
71
|
+
end
|
72
|
+
yield
|
73
|
+
ensure
|
74
|
+
@current = nil if no_current
|
75
|
+
end
|
76
|
+
|
77
|
+
# Direct access to each of the named descriptors
|
78
|
+
def stdin; @current[1]; end
|
79
|
+
def stdout; @current[2]; end
|
80
|
+
def stderr; @current[3]; end
|
81
|
+
|
82
|
+
def shell_params
|
83
|
+
if @user.nil?
|
84
|
+
Hash.new
|
85
|
+
else
|
86
|
+
{
|
87
|
+
:user => @user,
|
88
|
+
:environment => {
|
89
|
+
'USER' => @user,
|
90
|
+
'HOME' => Etc.getpwnam(@user).dir
|
91
|
+
}
|
92
|
+
}
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
::RVM::Shell.const_set('ChefWrapper', klass)
|
97
|
+
|
98
|
+
::RVM::Shell.default_wrapper = ::RVM::Shell::ChefWrapper
|
99
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
{
|
2
|
+
"name": "rvm",
|
3
|
+
"description": "Manages system-wide and per-user RVMs and manages installed Rubies. Several lightweight resources and providers (LWRP) are also defined.Installs and manages RVM. Includes several LWRPs.",
|
4
|
+
"long_description": "Please refer to README.md (it's long).",
|
5
|
+
"maintainer": "Fletcher Nichol",
|
6
|
+
"maintainer_email": "fnichol@nichol.ca",
|
7
|
+
"license": "Apache 2.0",
|
8
|
+
"platforms": {
|
9
|
+
"debian": ">= 0.0.0",
|
10
|
+
"ubuntu": ">= 0.0.0",
|
11
|
+
"suse": ">= 0.0.0",
|
12
|
+
"centos": ">= 0.0.0",
|
13
|
+
"amazon": ">= 0.0.0",
|
14
|
+
"redhat": ">= 0.0.0",
|
15
|
+
"fedora": ">= 0.0.0",
|
16
|
+
"gentoo": ">= 0.0.0",
|
17
|
+
"mac_os_x": ">= 0.0.0",
|
18
|
+
"mac_os_x_server": ">= 0.0.0"
|
19
|
+
},
|
20
|
+
"dependencies": {
|
21
|
+
"chef_gem": ">= 0.0.0"
|
22
|
+
},
|
23
|
+
"recommendations": {
|
24
|
+
"java": ">= 0.0.0"
|
25
|
+
},
|
26
|
+
"suggestions": {
|
27
|
+
"homebrew": ">= 0.0.0"
|
28
|
+
},
|
29
|
+
"conflicting": {
|
30
|
+
},
|
31
|
+
"providing": {
|
32
|
+
},
|
33
|
+
"replacing": {
|
34
|
+
},
|
35
|
+
"attributes": {
|
36
|
+
},
|
37
|
+
"groupings": {
|
38
|
+
},
|
39
|
+
"recipes": {
|
40
|
+
"rvm": "Installs the RVM gem and initializes Chef to use the Lightweight Resources and Providers (LWRPs). Use this recipe explicitly if you only want access to the LWRPs provided.",
|
41
|
+
"rvm::system_install": "Installs the RVM codebase system-wide (that is, into /usr/local/rvm). This recipe includes *default*. Use this recipe by itself if you want RVM installed system-wide but want to handle installing Rubies, invoking LWRPs, etc..",
|
42
|
+
"rvm::system": "Installs the RVM codebase system-wide (that is, into /usr/local/rvm) and installs Rubies, global gems, and specific gems driven off attribute metadata. This recipe includes *default* and *system_install*. Use this recipe by itself if you want RVM system-wide with Rubies installed, etc.",
|
43
|
+
"rvm::user_install": "Installs the RVM codebase for a list of users (selected from the node['rvm']['user_installs'] hash). This recipe includes *default*. Use this recipe by itself if you want RVM installed for specific users in isolation but want each user to handle installing Rubies, invoking LWRPs, etc.",
|
44
|
+
"rvm::user": "Installs the RVM codebase for a list of users (selected from the node['rvm']['user_installs'] hash) and installs Rubies, global gems, and specific gems driven off attribute metadata. This recipe includes *default* and *user_install*. Use this recipe by itself if you want RVM installed for specific users in isolation with Rubies installed, etc.",
|
45
|
+
"rvm::vagrant": "An optional recipe to help if running in a Vagrant virtual machine",
|
46
|
+
"rvm::gem_package": "An experimental recipe that patches the gem_package resource"
|
47
|
+
},
|
48
|
+
"version": "0.10.1",
|
49
|
+
"source_url": "",
|
50
|
+
"issues_url": ""
|
51
|
+
}
|