from-scratch 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (174) hide show
  1. checksums.yaml +7 -0
  2. data/.chef/knife.rb +6 -0
  3. data/.gitignore +9 -0
  4. data/.rspec +2 -0
  5. data/.travis.yml +4 -0
  6. data/Berksfile +17 -0
  7. data/Berksfile.lock +19 -0
  8. data/Gemfile +4 -0
  9. data/LICENSE.txt +21 -0
  10. data/README.md +58 -0
  11. data/Rakefile +6 -0
  12. data/Thorfile +5 -0
  13. data/bin/scratchify +6 -0
  14. data/chefignore +101 -0
  15. data/cookbooks/chef_gem/CHANGELOG.md +24 -0
  16. data/cookbooks/chef_gem/README.md +38 -0
  17. data/cookbooks/chef_gem/libraries/chef_gem.rb +72 -0
  18. data/cookbooks/chef_gem/metadata.json +29 -0
  19. data/cookbooks/chef_gem/recipes/default.rb +0 -0
  20. data/cookbooks/java/.gitignore +21 -0
  21. data/cookbooks/java/.kitchen.docker.yml +15 -0
  22. data/cookbooks/java/.kitchen.yml +126 -0
  23. data/cookbooks/java/.travis.yml +6 -0
  24. data/cookbooks/java/Berksfile +10 -0
  25. data/cookbooks/java/CHANGELOG.md +398 -0
  26. data/cookbooks/java/CONTRIBUTING.md +12 -0
  27. data/cookbooks/java/Gemfile +15 -0
  28. data/cookbooks/java/ISSUES.md +43 -0
  29. data/cookbooks/java/LICENSE +201 -0
  30. data/cookbooks/java/README.md +402 -0
  31. data/cookbooks/java/Rakefile +60 -0
  32. data/cookbooks/java/TESTING.md +41 -0
  33. data/cookbooks/java/attributes/default.rb +146 -0
  34. data/cookbooks/java/libraries/helpers.rb +120 -0
  35. data/cookbooks/java/libraries/matchers.rb +5 -0
  36. data/cookbooks/java/metadata.json +69 -0
  37. data/cookbooks/java/providers/alternatives.rb +94 -0
  38. data/cookbooks/java/providers/ark.rb +255 -0
  39. data/cookbooks/java/recipes/default.rb +22 -0
  40. data/cookbooks/java/recipes/default_java_symlink.rb +19 -0
  41. data/cookbooks/java/recipes/homebrew.rb +3 -0
  42. data/cookbooks/java/recipes/ibm.rb +76 -0
  43. data/cookbooks/java/recipes/ibm_tar.rb +70 -0
  44. data/cookbooks/java/recipes/openjdk.rb +74 -0
  45. data/cookbooks/java/recipes/oracle.rb +74 -0
  46. data/cookbooks/java/recipes/oracle_i386.rb +73 -0
  47. data/cookbooks/java/recipes/oracle_jce.rb +75 -0
  48. data/cookbooks/java/recipes/oracle_rpm.rb +60 -0
  49. data/cookbooks/java/recipes/purge_packages.rb +20 -0
  50. data/cookbooks/java/recipes/set_attributes_from_version.rb +55 -0
  51. data/cookbooks/java/recipes/set_java_home.rb +44 -0
  52. data/cookbooks/java/recipes/windows.rb +82 -0
  53. data/cookbooks/java/resources/alternatives.rb +30 -0
  54. data/cookbooks/java/resources/ark.rb +58 -0
  55. data/cookbooks/java/templates/default/ibm_jdk.installer.properties.erb +3 -0
  56. data/cookbooks/java/templates/default/oracle.jinfo.erb +6 -0
  57. data/cookbooks/rvm/.foodcritic +1 -0
  58. data/cookbooks/rvm/.gitignore +7 -0
  59. data/cookbooks/rvm/.kitchen.yml +66 -0
  60. data/cookbooks/rvm/.travis.yml +9 -0
  61. data/cookbooks/rvm/Berksfile +10 -0
  62. data/cookbooks/rvm/CHANGELOG.md +253 -0
  63. data/cookbooks/rvm/CODE_OF_CONDUCT.md +12 -0
  64. data/cookbooks/rvm/CONTRIBUTING.md +26 -0
  65. data/cookbooks/rvm/Gemfile +20 -0
  66. data/cookbooks/rvm/Guardfile +12 -0
  67. data/cookbooks/rvm/README.md +1459 -0
  68. data/cookbooks/rvm/Rakefile +18 -0
  69. data/cookbooks/rvm/attributes/.gitkeep +0 -0
  70. data/cookbooks/rvm/attributes/default.rb +68 -0
  71. data/cookbooks/rvm/attributes/gem_package.rb +23 -0
  72. data/cookbooks/rvm/attributes/vagrant.rb +23 -0
  73. data/cookbooks/rvm/libraries/chef_rvm_environment_helpers.rb +55 -0
  74. data/cookbooks/rvm/libraries/chef_rvm_gemset_helpers.rb +67 -0
  75. data/cookbooks/rvm/libraries/chef_rvm_recipe_helpers.rb +80 -0
  76. data/cookbooks/rvm/libraries/chef_rvm_ruby_helpers.rb +95 -0
  77. data/cookbooks/rvm/libraries/chef_rvm_set_helpers.rb +16 -0
  78. data/cookbooks/rvm/libraries/chef_rvm_shell_helpers.rb +57 -0
  79. data/cookbooks/rvm/libraries/chef_rvm_string_cache.rb +104 -0
  80. data/cookbooks/rvm/libraries/chef_rvm_string_helpers.rb +61 -0
  81. data/cookbooks/rvm/libraries/chef_rvm_version_helpers.rb +45 -0
  82. data/cookbooks/rvm/libraries/gem_package_monkeypatch.rb +34 -0
  83. data/cookbooks/rvm/libraries/provider_rvm_installation.rb +185 -0
  84. data/cookbooks/rvm/libraries/resource_rvm_installation.rb +103 -0
  85. data/cookbooks/rvm/libraries/rvm_chef_user_environment.rb +55 -0
  86. data/cookbooks/rvm/libraries/rvm_rubygems_package.rb +189 -0
  87. data/cookbooks/rvm/libraries/rvm_shell_chef_wrapper.rb +99 -0
  88. data/cookbooks/rvm/metadata.json +51 -0
  89. data/cookbooks/rvm/providers/default_ruby.rb +63 -0
  90. data/cookbooks/rvm/providers/environment.rb +78 -0
  91. data/cookbooks/rvm/providers/gemset.rb +118 -0
  92. data/cookbooks/rvm/providers/global_gem.rb +97 -0
  93. data/cookbooks/rvm/providers/ruby.rb +178 -0
  94. data/cookbooks/rvm/providers/shell.rb +121 -0
  95. data/cookbooks/rvm/providers/wrapper.rb +73 -0
  96. data/cookbooks/rvm/recipes/.gitkeep +0 -0
  97. data/cookbooks/rvm/recipes/default.rb +40 -0
  98. data/cookbooks/rvm/recipes/gem_package.rb +33 -0
  99. data/cookbooks/rvm/recipes/system.rb +37 -0
  100. data/cookbooks/rvm/recipes/system_install.rb +42 -0
  101. data/cookbooks/rvm/recipes/user.rb +43 -0
  102. data/cookbooks/rvm/recipes/user_install.rb +58 -0
  103. data/cookbooks/rvm/recipes/vagrant.rb +37 -0
  104. data/cookbooks/rvm/resources/default_ruby.rb +31 -0
  105. data/cookbooks/rvm/resources/environment.rb +31 -0
  106. data/cookbooks/rvm/resources/gem.rb +37 -0
  107. data/cookbooks/rvm/resources/gemset.rb +32 -0
  108. data/cookbooks/rvm/resources/global_gem.rb +34 -0
  109. data/cookbooks/rvm/resources/ruby.rb +32 -0
  110. data/cookbooks/rvm/resources/shell.rb +41 -0
  111. data/cookbooks/rvm/resources/wrapper.rb +34 -0
  112. data/cookbooks/rvm/templates/default/rvmrc.erb +14 -0
  113. data/cookbooks/rvm/templates/default/vagrant-chef-client-wrapper.erb +23 -0
  114. data/cookbooks/rvm/templates/default/vagrant-chef-solo-wrapper.erb +23 -0
  115. data/cookbooks/rvm/test/integration/data_bags/users/virgil1.json +4 -0
  116. data/cookbooks/rvm/test/integration/data_bags/users/virgil2.json +4 -0
  117. data/cookbooks/rvm/test/integration/data_bags/users/wigglebottom.json +3 -0
  118. data/cookbooks/rvm/test/integration/installs/bats/version_pinning.bats +13 -0
  119. data/cookbooks/rvm/test/integration/rubies/bats/_common.bash +16 -0
  120. data/cookbooks/rvm/test/integration/rubies/bats/verify_1.9.3.bats +9 -0
  121. data/cookbooks/rvm/test/integration/rubies/bats/verify_jruby.bats +12 -0
  122. data/cookbooks/rvm/test/integration/rubies/bats/verify_patch_support.bats +19 -0
  123. data/cookbooks/rvm/test/integration/rubies/bats/verify_ree.bats +9 -0
  124. data/cookbooks/rvm/test/integration/rubies/bats/verify_rubygems_version_support.bats +15 -0
  125. data/cookbooks/rvm/test/integration/stock_system_and_user/bats/system.bats +45 -0
  126. data/cookbooks/rvm/test/unit/libraries/provider_rvm_installation_spec.rb +220 -0
  127. data/cookbooks/rvm/test/unit/libraries/resource_rvm_installation_spec.rb +139 -0
  128. data/cookbooks/rvm/test/unit/spec_helper.rb +23 -0
  129. data/cookbooks/scratchify/.chef/knife.rb +9 -0
  130. data/cookbooks/scratchify/Berksfile +16 -0
  131. data/cookbooks/scratchify/Berksfile.lock +19 -0
  132. data/cookbooks/scratchify/LICENSE.txt +21 -0
  133. data/cookbooks/scratchify/README.md +41 -0
  134. data/cookbooks/scratchify/Thorfile +5 -0
  135. data/cookbooks/scratchify/bin/console +14 -0
  136. data/cookbooks/scratchify/bin/scratchify +6 -0
  137. data/cookbooks/scratchify/bin/setup +7 -0
  138. data/cookbooks/scratchify/chefignore +101 -0
  139. data/cookbooks/scratchify/data_bags/users/deploy.json +6 -0
  140. data/cookbooks/scratchify/environments/.gitkeep +0 -0
  141. data/cookbooks/scratchify/from-scratch.gemspec +36 -0
  142. data/cookbooks/scratchify/lib/from/scratch.rb +31 -0
  143. data/cookbooks/scratchify/lib/from/scratch/interviewer.rb +35 -0
  144. data/cookbooks/scratchify/lib/from/scratch/version.rb +3 -0
  145. data/cookbooks/scratchify/metadata.json +36 -0
  146. data/cookbooks/scratchify/nodes/normfood.ru.json +75 -0
  147. data/cookbooks/scratchify/recipes/default.rb +0 -0
  148. data/cookbooks/scratchify/roles/.gitkeep +0 -0
  149. data/cookbooks/scratchify/spec/from/scratch_spec.rb +11 -0
  150. data/cookbooks/scratchify/spec/spec_helper.rb +2 -0
  151. data/cookbooks/user/.gitignore +5 -0
  152. data/cookbooks/user/.kitchen.yml +46 -0
  153. data/cookbooks/user/.travis.yml +4 -0
  154. data/cookbooks/user/Berksfile +7 -0
  155. data/cookbooks/user/CHANGELOG.md +101 -0
  156. data/cookbooks/user/Gemfile +14 -0
  157. data/cookbooks/user/README.md +447 -0
  158. data/cookbooks/user/Rakefile +21 -0
  159. data/cookbooks/user/attributes/default.rb +50 -0
  160. data/cookbooks/user/libraries/matchers.rb +26 -0
  161. data/cookbooks/user/metadata.json +46 -0
  162. data/cookbooks/user/providers/account.rb +212 -0
  163. data/cookbooks/user/recipes/data_bag.rb +59 -0
  164. data/cookbooks/user/recipes/default.rb +18 -0
  165. data/cookbooks/user/resources/account.rb +41 -0
  166. data/cookbooks/user/templates/default/authorized_keys.erb +7 -0
  167. data/from-scratch.gemspec +33 -0
  168. data/lib/from-scratch.rb +25 -0
  169. data/lib/from-scratch/version.rb +3 -0
  170. data/metadata.rb +15 -0
  171. data/recipes/default.rb +0 -0
  172. data/templates/node.json.erb +31 -0
  173. data/templates/user.json.erb +6 -0
  174. metadata +330 -0
@@ -0,0 +1,121 @@
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
+ include Chef::RVM::StringHelpers
23
+ include Chef::RVM::EnvironmentHelpers
24
+ include Chef::RVM::ShellHelpers
25
+
26
+ def load_current_resource
27
+ @user_rvm = user_installed_rvm? ? new_resource.user : nil
28
+ @rubie = normalize_ruby_string(select_ruby(new_resource.ruby_string), @user_rvm)
29
+ @gemset = select_gemset(new_resource.ruby_string)
30
+ @ruby_string = @gemset.nil? ? @rubie : "#{@rubie}@#{@gemset}"
31
+ @rvm_env = ::RVM::ChefUserEnvironment.new(@user_rvm)
32
+ end
33
+
34
+ action :run do
35
+ user_rvm = @user_rvm
36
+
37
+ # ensure ruby is installed and gemset exists
38
+ unless env_exists?(@ruby_string)
39
+ e = rvm_environment @ruby_string do
40
+ user user_rvm
41
+ action :nothing
42
+ end
43
+ e.run_action(:create)
44
+ end
45
+
46
+ script_wrapper :run
47
+ new_resource.updated_by_last_action(true)
48
+ end
49
+
50
+ private
51
+
52
+ ##
53
+ # Wraps the script resource for RVM-dependent code.
54
+ #
55
+ # @param [Symbol] action to be performed with gem_package provider
56
+ def script_wrapper(exec_action)
57
+ profile = find_profile_to_source
58
+
59
+ script_code = <<-CODE
60
+ if [ -s "${HOME}/.rvm/scripts/rvm" ]; then
61
+ source "${HOME}/.rvm/scripts/rvm"
62
+ elif [ -s "#{profile}" ]; then
63
+ source "#{profile}"
64
+ fi
65
+
66
+ rvm use #{@ruby_string}
67
+
68
+ #{new_resource.code}
69
+ CODE
70
+
71
+ if new_resource.user
72
+ user_rvm = user_installed_rvm?
73
+ user_home = user_dir
74
+ end
75
+
76
+ s = script new_resource.name do
77
+ interpreter "bash"
78
+
79
+ if new_resource.user
80
+ user new_resource.user
81
+ if user_rvm && new_resource.environment
82
+ environment({ 'USER' => new_resource.user, 'HOME' => user_home }.merge(
83
+ new_resource.environment))
84
+ elsif user_rvm
85
+ environment({ 'USER' => new_resource.user, 'HOME' => user_home })
86
+ end
87
+ end
88
+
89
+ code script_code
90
+ creates new_resource.creates if new_resource.creates
91
+ cwd new_resource.cwd if new_resource.cwd
92
+ group new_resource.group if new_resource.group
93
+ path new_resource.path if new_resource.path
94
+ returns new_resource.returns if new_resource.returns
95
+ timeout new_resource.timeout if new_resource.timeout
96
+ umask new_resource.umask if new_resource.umask
97
+ action :nothing
98
+ end
99
+ s.run_action(exec_action)
100
+ new_resource.updated_by_last_action(true) if s.updated_by_last_action?
101
+ end
102
+
103
+ ##
104
+ # Whether or not the user has an isolated RVM installation
105
+ #
106
+ # @return [true,false] does the user have RVM installed for themselves?
107
+ def user_installed_rvm?
108
+ return false unless new_resource.user
109
+
110
+ ::File.exists?("#{user_dir}/.rvm/VERSION")
111
+ end
112
+
113
+ ##
114
+ # Determines the user's home directory
115
+ #
116
+ # @return [String] the path to the user's home directory
117
+ def user_dir
118
+ return nil unless new_resource.user
119
+
120
+ Etc.getpwnam(new_resource.user).dir
121
+ end
@@ -0,0 +1,73 @@
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
+ 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
+
31
+ if new_resource.binary.nil?
32
+ @binaries = new_resource.binaries || []
33
+ else
34
+ @binaries = [ new_resource.binary ] || []
35
+ end
36
+ end
37
+
38
+ action :create do
39
+ # ensure ruby is installed and gemset exists
40
+ unless env_exists?(@ruby_string)
41
+ e = rvm_environment @ruby_string do
42
+ user new_resource.user
43
+ action :nothing
44
+ end
45
+ e.run_action(:create)
46
+ end
47
+
48
+ @rvm_env.use @ruby_string
49
+
50
+ @binaries.each { |b| create_wrapper(b) }
51
+ new_resource.updated_by_last_action(true)
52
+ end
53
+
54
+ private
55
+
56
+ def create_wrapper(bin)
57
+ full_bin = "#{new_resource.prefix}_#{bin}"
58
+ resource_name = "rvm_wrapper[#{full_bin}::#{@ruby_string}]"
59
+ script = ::File.join(@rvm_env.config["rvm_path"], "bin", full_bin)
60
+
61
+ if ::File.exists?(script)
62
+ Chef::Log.debug("#{resource_name} already exists, so updating")
63
+ else
64
+ Chef::Log.info("Creating #{resource_name}")
65
+ end
66
+
67
+ if @rvm_env.wrapper @ruby_string, new_resource.prefix, bin
68
+ Chef::Log.debug("Creation/Update of #{resource_name} was successful.")
69
+ new_resource.updated_by_last_action(true)
70
+ else
71
+ Chef::Log.warn("Failed to create/update #{resource_name}.")
72
+ end
73
+ end
File without changes
@@ -0,0 +1,40 @@
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
+ # install rvm api gem during chef compile phase
21
+ chef_gem 'rvm' do
22
+ action :install
23
+ version '>= 1.11.3.6'
24
+ end
25
+ require 'rvm'
26
+
27
+ create_rvm_shell_chef_wrapper
28
+ create_rvm_chef_user_environment
29
+
30
+ class Chef::Resource
31
+ # mix in #rvm_cmd_wrap helper into resources
32
+ include Chef::RVM::ShellHelpers
33
+ end
34
+
35
+ class Chef::Recipe
36
+ # mix in recipe helpers
37
+ include Chef::RVM::ShellHelpers
38
+ include Chef::RVM::RecipeHelpers
39
+ include Chef::RVM::StringHelpers
40
+ end
@@ -0,0 +1,33 @@
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
+ node_val = node['rvm']['gem_package']['rvm_string']
21
+ case node_val
22
+ when String
23
+ rvm_descriptor = node_val + " RVM Ruby"
24
+ when Array
25
+ last = node_val.pop
26
+ rvm_descriptor = [ node_val.join(', '), last ].join(' & ') + " RVM Rubies"
27
+ end
28
+
29
+ patch_gem_package
30
+
31
+ ::Chef::Log.info "gem_package resource has been patched to use provider " <<
32
+ "Chef::Provider::Package::RVMRubygems and will install gems to " <<
33
+ "the #{rvm_descriptor}."
@@ -0,0 +1,37 @@
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
+ include_recipe "rvm::system_install"
21
+
22
+ perform_install_rubies = node['rvm']['install_rubies'] == true ||
23
+ node['rvm']['install_rubies'] == "true"
24
+
25
+ if perform_install_rubies
26
+ install_rubies :rubies => node['rvm']['rubies'],
27
+ :default_ruby => node['rvm']['default_ruby'],
28
+ :global_gems => node['rvm']['global_gems'],
29
+ :gems => node['rvm']['gems']
30
+ end
31
+
32
+ # add users to rvm group
33
+ group 'rvm' do
34
+ members node['rvm']['group_users']
35
+
36
+ only_if { node['rvm']['group_users'].any? }
37
+ end
@@ -0,0 +1,42 @@
1
+ #
2
+ # Cookbook Name:: rvm
3
+ # Recipe:: system_install
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
+ include_recipe 'rvm'
21
+
22
+ # Build the rvm group ahead of time, if it is set. This allows avoiding
23
+ # collision with later processes which may set a guid explicitly
24
+ if node['rvm']['group_id'] != 'default'
25
+ g = group 'rvm' do
26
+ group_name 'rvm'
27
+ gid node['rvm']['group_id']
28
+ action :nothing
29
+ end
30
+ g.run_action(:create)
31
+ end
32
+
33
+ key_server = node['rvm']['gpg']['keyserver'] || "hkp://keys.gnupg.net"
34
+ home_dir = "#{node['rvm']['gpg']['homedir'] || '~'}/.gnupg"
35
+
36
+ execute 'Adding gpg key' do
37
+ command "`which gpg2 || which gpg` --keyserver #{key_server} --homedir #{home_dir} --recv-keys #{node['rvm']['gpg_key']}"
38
+ only_if 'which gpg2 || which gpg'
39
+ not_if { node['rvm']['gpg_key'].empty? }
40
+ end
41
+
42
+ rvm_installation("root")
@@ -0,0 +1,43 @@
1
+ #
2
+ # Cookbook Name:: rvm
3
+ # Recipe:: user
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
+ include_recipe 'rvm::user_install'
21
+
22
+ Array(node['rvm']['user_installs']).each do |rvm_user|
23
+ perform_install_rubies = rvm_user['install_rubies'] == true ||
24
+ rvm_user['install_rubies'] == "true" ||
25
+ node['rvm']['user_install_rubies'] == true ||
26
+ node['rvm']['user_install_rubies'] == "true"
27
+ rubies = rvm_user['rubies'] ||
28
+ node['rvm']['user_rubies']
29
+ default_ruby = rvm_user['default_ruby'] ||
30
+ node['rvm']['user_default_ruby']
31
+ global_gems = rvm_user['global_gems'] ||
32
+ node['rvm']['user_global_gems']
33
+ gems = rvm_user['gems'] ||
34
+ node['rvm']['user_gems']
35
+
36
+ if perform_install_rubies
37
+ install_rubies :rubies => rubies,
38
+ :default_ruby => default_ruby,
39
+ :global_gems => global_gems,
40
+ :gems => gems,
41
+ :user => rvm_user['user']
42
+ end
43
+ end
@@ -0,0 +1,58 @@
1
+ #
2
+ # Cookbook Name:: rvm
3
+ # Recipe:: user_install
4
+ #
5
+ # Copyright 2011, 2012, 2013 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
+ include_recipe "rvm"
21
+
22
+ node["rvm"]["installs"].each do |user, opts|
23
+ # if user hash is falsy (nil, false) then we're not installing
24
+ next unless opts
25
+
26
+ # if user hash is not a hash (i.e. set to true), init an empty Hash
27
+ opts = Hash.new if opts == true
28
+
29
+ ruby_block "Conditionally add RVM gpg key" do # ~FC022 this will be fixed in the LWRP rewrite
30
+ block do
31
+ cmd = Mixlib::ShellOut.new('which gpg2 || which gpg')
32
+ cmd.run_command
33
+
34
+ if cmd.exitstatus == 0
35
+ gpg_command = cmd.stdout.chomp
36
+
37
+ exec = Chef::Resource::Execute.new 'Add RVM gpg key', run_context
38
+ exec.command "#{gpg_command} --keyserver hkp://keys.gnupg.net --recv-keys #{node['rvm']['gpg_key']}"
39
+ exec.user user['user']
40
+ exec.environment 'HOME' => user['home']
41
+ exec.guard_interpreter :bash
42
+ exec.not_if "#{gpg_command} -k #{node['rvm']['gpg_key']} > /dev/null", user: user['user'], environment: { 'HOME' => user['home'] }
43
+ exec.run_action :run
44
+ else
45
+ Chef::Log.info 'Skipping adding RVM key because gpg/gpg2 not installed'
46
+ end
47
+ end
48
+ end
49
+
50
+ rvm_installation(user.to_s) do
51
+ %w(installer_url installer_flags install_pkgs rvmrc_template_source
52
+ rvmrc_template_cookbook rvmrc_env action
53
+ ).each do |attr|
54
+ # if user hash attr is set, then set the resource attr
55
+ send(attr, opts[attr]) if opts.fetch(attr, false)
56
+ end
57
+ end
58
+ end