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,74 @@
1
+ # Author:: Bryan W. Berry (<bryan.berry@gmail.com>)
2
+ # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
+ # Author:: Joshua Timberman (<joshua@opscode.com>)
4
+ #
5
+ # Cookbook Name:: java
6
+ # Recipe:: openjdk
7
+ #
8
+ # Copyright 2010-2013, Opscode, Inc.
9
+ #
10
+ # Licensed under the Apache License, Version 2.0 (the "License");
11
+ # you may not use this file except in compliance with the License.
12
+ # You may obtain a copy of the License at
13
+ #
14
+ # http://www.apache.org/licenses/LICENSE-2.0
15
+ #
16
+ # Unless required by applicable law or agreed to in writing, software
17
+ # distributed under the License is distributed on an "AS IS" BASIS,
18
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ # See the License for the specific language governing permissions and
20
+ # limitations under the License.
21
+
22
+ unless node.recipe?('java::default')
23
+ Chef::Log.warn("Using java::default instead is recommended.")
24
+
25
+ # Even if this recipe is included by itself, a safety check is nice...
26
+ [ node['java']['openjdk_packages'], node['java']['java_home'] ].each do |v|
27
+ if v.nil? or v.empty?
28
+ include_recipe "java::set_attributes_from_version"
29
+ end
30
+ end
31
+ end
32
+
33
+ jdk = Opscode::OpenJDK.new(node)
34
+
35
+ if platform_requires_license_acceptance?
36
+ file "/opt/local/.dlj_license_accepted" do
37
+ owner "root"
38
+ group "root"
39
+ mode "0400"
40
+ action :create
41
+ only_if { node['java']['accept_license_agreement'] }
42
+ end
43
+ end
44
+
45
+ node['java']['openjdk_packages'].each do |pkg|
46
+ package pkg do
47
+ version node['java']['openjdk_version'] if node['java']['openjdk_version']
48
+ end
49
+ end
50
+
51
+ if platform_family?('debian', 'rhel', 'fedora')
52
+ java_alternatives 'set-java-alternatives' do
53
+ java_location jdk.java_home
54
+ default node['java']['set_default']
55
+ priority jdk.alternatives_priority
56
+ case node['java']['jdk_version'].to_s
57
+ when "6"
58
+ bin_cmds node['java']['jdk']['6']['bin_cmds']
59
+ when "7"
60
+ bin_cmds node['java']['jdk']['7']['bin_cmds']
61
+ when "8"
62
+ bin_cmds node['java']['jdk']['8']['bin_cmds']
63
+ end
64
+ action :set
65
+ end
66
+ end
67
+
68
+ if node['java']['set_default'] and platform_family?('debian')
69
+ include_recipe 'java::default_java_symlink'
70
+ end
71
+
72
+ # We must include this recipe AFTER updating the alternatives or else JAVA_HOME
73
+ # will not point to the correct java.
74
+ include_recipe 'java::set_java_home'
@@ -0,0 +1,74 @@
1
+ #
2
+ # Author:: Bryan W. Berry (<bryan.berry@gmail.com>)
3
+ # Cookbook Name:: java
4
+ # Recipe:: oracle
5
+ #
6
+ # Copyright 2011, Bryan w. Berry
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+
20
+ unless node.recipe?('java::default')
21
+ Chef::Log.warn("Using java::default instead is recommended.")
22
+
23
+ # Even if this recipe is included by itself, a safety check is nice...
24
+ if node['java']['java_home'].nil? or node['java']['java_home'].empty?
25
+ include_recipe "java::set_attributes_from_version"
26
+ end
27
+ end
28
+
29
+ java_home = node['java']["java_home"]
30
+ arch = node['java']['arch']
31
+
32
+ case node['java']['jdk_version'].to_s
33
+ when "6"
34
+ tarball_url = node['java']['jdk']['6'][arch]['url']
35
+ tarball_checksum = node['java']['jdk']['6'][arch]['checksum']
36
+ bin_cmds = node['java']['jdk']['6']['bin_cmds']
37
+ when "7"
38
+ tarball_url = node['java']['jdk']['7'][arch]['url']
39
+ tarball_checksum = node['java']['jdk']['7'][arch]['checksum']
40
+ bin_cmds = node['java']['jdk']['7']['bin_cmds']
41
+ when "8"
42
+ tarball_url = node['java']['jdk']['8'][arch]['url']
43
+ tarball_checksum = node['java']['jdk']['8'][arch]['checksum']
44
+ bin_cmds = node['java']['jdk']['8']['bin_cmds']
45
+ end
46
+
47
+ if tarball_url =~ /example.com/
48
+ Chef::Application.fatal!("You must change the download link to your private repository. You can no longer download java directly from http://download.oracle.com without a web broswer")
49
+ end
50
+
51
+ include_recipe "java::set_java_home"
52
+
53
+ package "tar"
54
+
55
+ java_ark "jdk" do
56
+ url tarball_url
57
+ default node['java']['set_default']
58
+ checksum tarball_checksum
59
+ app_home java_home
60
+ bin_cmds bin_cmds
61
+ alternatives_priority node['java']['alternatives_priority']
62
+ retries node['java']['ark_retries']
63
+ retry_delay node['java']['ark_retry_delay']
64
+ connect_timeout node['java']['ark_timeout']
65
+ use_alt_suffix node['java']['use_alt_suffix']
66
+ reset_alternatives node['java']['reset_alternatives']
67
+ action :install
68
+ end
69
+
70
+ if node['java']['set_default'] and platform_family?('debian')
71
+ include_recipe 'java::default_java_symlink'
72
+ end
73
+
74
+ include_recipe 'java::oracle_jce' if node['java']['oracle']['jce']['enabled']
@@ -0,0 +1,73 @@
1
+ #
2
+ # Author:: Bryan W. Berry (<bryan.berry@gmail.com>)
3
+ # Cookbook Name:: java
4
+ # Recipe:: oracle_i386
5
+ #
6
+ # Copyright 2010-2011, Opscode, Inc.
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+
20
+ unless node.recipe?('java::default')
21
+ Chef::Log.warn("Using java::default instead is recommended.")
22
+
23
+ # Even if this recipe is included by itself, a safety check is nice...
24
+ if node['java']['java_home'].nil? or node['java']['java_home'].empty?
25
+ include_recipe "java::set_attributes_from_version"
26
+ end
27
+ end
28
+
29
+ java_home = node['java']["java_home"]
30
+
31
+ case node['java']['jdk_version'].to_s
32
+ when "6"
33
+ tarball_url = node['java']['jdk']['6']['i586']['url']
34
+ tarball_checksum = node['java']['jdk']['6']['i586']['checksum']
35
+ bin_cmds = node['java']['jdk']['6']['bin_cmds']
36
+ when "7"
37
+ tarball_url = node['java']['jdk']['7']['i586']['url']
38
+ tarball_checksum = node['java']['jdk']['7']['i586']['checksum']
39
+ bin_cmds = node['java']['jdk']['7']['bin_cmds']
40
+ when "8"
41
+ tarball_url = node['java']['jdk']['8']['i586']['url']
42
+ tarball_checksum = node['java']['jdk']['8']['i586']['checksum']
43
+ bin_cmds = node['java']['jdk']['8']['bin_cmds']
44
+ end
45
+
46
+ include_recipe "java::set_java_home"
47
+
48
+ yum_package "glibc" do
49
+ arch "i686"
50
+ only_if { platform_family?( "rhel", "fedora" ) }
51
+ end
52
+
53
+ package "tar"
54
+
55
+ java_ark "jdk-alt" do
56
+ url tarball_url
57
+ default node['java']['set_default']
58
+ checksum tarball_checksum
59
+ app_home java_home
60
+ bin_cmds bin_cmds
61
+ retries node['java']['ark_retries']
62
+ retry_delay node['java']['ark_retries']
63
+ use_alt_suffix node['java']['use_alt_suffix']
64
+ reset_alternatives node['java']['reset_alternatives']
65
+ action :install
66
+ default false
67
+ end
68
+
69
+ if node['java']['set_default'] and platform_family?('debian')
70
+ include_recipe 'java::default_java_symlink'
71
+ end
72
+
73
+ include_recipe 'java::oracle_jce' if node['java']['oracle']['jce']['enabled']
@@ -0,0 +1,75 @@
1
+ #
2
+ # Author:: Kyle McGovern (<spion06@gmail.com>)
3
+ # Cookbook Name:: java
4
+ # Recipe:: oracle_jce
5
+ #
6
+ # Copyright 2014, Kyle McGovern
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+
20
+ include_recipe 'java::set_attributes_from_version'
21
+
22
+ jdk_version = node['java']['jdk_version'].to_s
23
+ jce_url = node['java']['oracle']['jce'][jdk_version]['url']
24
+ jce_checksum = node['java']['oracle']['jce'][jdk_version]['checksum']
25
+ jce_cookie = node['java']['oracle']['accept_oracle_download_terms'] ? 'oraclelicense=accept-securebackup-cookie;gpw_e24=http://edelivery.oracle.com' : ''
26
+
27
+ if jce_checksum =~ /^[0-9a-f]{32}$/
28
+ checksum_bin = "md5sum"
29
+ else
30
+ checksum_bin = "sha256sum"
31
+ end
32
+
33
+ package "unzip"
34
+ package "curl"
35
+
36
+ directory ::File.join(node['java']['oracle']['jce']['home'],jdk_version) do
37
+ mode '0755'
38
+ recursive true
39
+ end
40
+
41
+ execute 'download jce' do
42
+ command <<-EOF
43
+ rm -rf #{Chef::Config[:file_cache_path]}/java_jce
44
+ mkdir -p #{Chef::Config[:file_cache_path]}/java_jce
45
+ cd #{Chef::Config[:file_cache_path]}/java_jce
46
+
47
+ curl -L --cookie '#{jce_cookie}' -o jce.zip #{jce_url}
48
+ # fail the resource if the checksum does not match
49
+ # this should only happen if oracle download terms are not accepted and downloading directly from oracle
50
+ echo "#{jce_checksum} jce.zip" | #{checksum_bin} -c >/dev/null
51
+ EOF
52
+ # if jar is already in the right location then don't need to download the JCE again
53
+ not_if { ::File.exist?( ::File.join(node['java']['oracle']['jce']['home'], jdk_version,'US_export_policy.jar') ) }
54
+ end
55
+
56
+ execute 'extract jce' do
57
+ command <<-EOF
58
+ unzip -o jce.zip
59
+ find -name '*.jar' | xargs -I JCE_JAR mv JCE_JAR #{node['java']['oracle']['jce']['home']}/#{jdk_version}/
60
+ EOF
61
+ cwd "#{Chef::Config[:file_cache_path]}/java_jce"
62
+ creates ::File.join(node['java']['oracle']['jce']['home'], jdk_version,'US_export_policy.jar')
63
+ end
64
+
65
+ %w(local_policy.jar US_export_policy.jar).each do |jar|
66
+ jar_path = ::File.join(node['java']['java_home'], 'jre', 'lib', 'security', jar)
67
+ # remove the jars already in the directory
68
+ file jar_path do
69
+ action :delete
70
+ not_if {::File.symlink? jar_path}
71
+ end
72
+ link jar_path do
73
+ to ::File.join(node['java']['oracle']['jce']['home'], jdk_version, jar)
74
+ end
75
+ end
@@ -0,0 +1,60 @@
1
+ # Author:: Christophe Arguel (<christophe.arguel@free.fr>)
2
+ #
3
+ # Cookbook Name:: java
4
+ # Recipe:: oracle_rpm
5
+ #
6
+ # Copyright 2013, Christophe Arguel <christophe.arguel@free.fr>
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+
20
+ include_recipe 'java::set_java_home'
21
+
22
+
23
+ slave_cmds = case node['java']['oracle_rpm']['type']
24
+ when 'jdk'
25
+ %W[appletviewer apt ControlPanel extcheck idlj jar jarsigner javac javadoc javafxpackager javah javap java-rmi.cgi javaws jcmd jconsole jcontrol jdb jhat jinfo jmap jps jrunscript jsadebugd jstack jstat jstatd jvisualvm keytool native2ascii orbd pack200 policytool rmic rmid rmiregistry schemagen serialver servertool tnameserv unpack200 wsgen wsimport xjc]
26
+
27
+ when 'jre'
28
+ %W[ControlPanel java_vm javaws jcontrol keytool orbd pack200 policytool rmid rmiregistry servertool tnameserv unpack200]
29
+
30
+ else
31
+ Chef::Application.fatal "Unsupported oracle RPM type (#{node['java']['oracle_rpm']['type']})"
32
+ end
33
+
34
+ if platform_family?('rhel', 'fedora') and node['java']['set_default']
35
+
36
+ bash 'update-java-alternatives' do
37
+ java_home = node['java']['java_home']
38
+ java_location = File.join(java_home, "bin", "java")
39
+ slave_lines = slave_cmds.inject("") do |slaves, cmd|
40
+ slaves << "--slave /usr/bin/#{cmd} #{cmd} #{File.join(java_home, "bin", cmd)} \\\n"
41
+ end
42
+
43
+ code <<-EOH.gsub(/^\s+/, '')
44
+ update-alternatives --install /usr/bin/java java #{java_location} 1061 \
45
+ #{slave_lines} && \
46
+ update-alternatives --set java #{java_location}
47
+ EOH
48
+ action :nothing
49
+ end
50
+
51
+ end
52
+
53
+ package_name = node['java']['oracle_rpm']['package_name'] || node['java']['oracle_rpm']['type']
54
+ package package_name do
55
+ action :install
56
+ version node['java']['oracle_rpm']['package_version'] if node['java']['oracle_rpm']['package_version']
57
+ notifies :run, 'bash[update-java-alternatives]', :immediately if platform_family?('rhel', 'fedora') and node['java']['set_default']
58
+ end
59
+
60
+ include_recipe 'java::oracle_jce' if node['java']['oracle']['jce']['enabled']
@@ -0,0 +1,20 @@
1
+ # Cookbook Name:: java
2
+ # Recipe:: purge_packages
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ %w[sun-java6-jdk sun-java6-bin sun-java6-jre].each do |pkg|
17
+ package pkg do
18
+ action :purge
19
+ end
20
+ end
@@ -0,0 +1,55 @@
1
+ # Cookbook Name:: java
2
+ # Recipe:: set_attributes_from_version
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ # Calculate variables that depend on jdk_version
17
+ # If you need to override this in an attribute file you must use
18
+ # force_default or higher precedence.
19
+
20
+ case node['platform_family']
21
+ when "rhel", "fedora"
22
+ case node['java']['install_flavor']
23
+ when "oracle"
24
+ node.default['java']['java_home'] = "/usr/lib/jvm/java"
25
+ when "oracle_rpm"
26
+ node.default['java']['java_home'] = "/usr/java/latest"
27
+ else
28
+ node.default['java']['java_home'] = "/usr/lib/jvm/java-1.#{node['java']['jdk_version']}.0"
29
+ end
30
+ node.default['java']['openjdk_packages'] = ["java-1.#{node['java']['jdk_version']}.0-openjdk", "java-1.#{node['java']['jdk_version']}.0-openjdk-devel"]
31
+ when "freebsd"
32
+ node.default['java']['java_home'] = "/usr/local/openjdk#{node['java']['jdk_version']}"
33
+ node.default['java']['openjdk_packages'] = ["openjdk#{node['java']['jdk_version']}"]
34
+ when "arch"
35
+ node.default['java']['java_home'] = "/usr/lib/jvm/java-#{node['java']['jdk_version']}-openjdk"
36
+ node.default['java']['openjdk_packages'] = ["openjdk#{node['java']['jdk_version']}"]
37
+ when "debian"
38
+ node.default['java']['java_home'] = "/usr/lib/jvm/java-#{node['java']['jdk_version']}-#{node['java']['install_flavor']}"
39
+ # Newer Debian & Ubuntu adds the architecture to the path
40
+ if node['platform'] == 'debian' && Chef::VersionConstraint.new(">= 7.0").include?(node['platform_version']) ||
41
+ node['platform'] == 'ubuntu' && Chef::VersionConstraint.new(">= 12.04").include?(node['platform_version'])
42
+ node.default['java']['java_home'] = "#{node['java']['java_home']}-#{node['kernel']['machine'] == 'x86_64' ? 'amd64' : 'i386'}"
43
+ end
44
+ node.default['java']['openjdk_packages'] = ["openjdk-#{node['java']['jdk_version']}-jdk", "openjdk-#{node['java']['jdk_version']}-jre-headless"]
45
+ when "smartos"
46
+ node.default['java']['java_home'] = "/opt/local/java/sun6"
47
+ node.default['java']['openjdk_packages'] = ["sun-jdk#{node['java']['jdk_version']}", "sun-jre#{node['java']['jdk_version']}"]
48
+ when "windows"
49
+ # Do nothing otherwise we will fall through to the else and set java_home to an invalid path, causing the installer to popup a dialog
50
+ when "macosx"
51
+ # Nothing. Homebrew driven.
52
+ else
53
+ node.default['java']['java_home'] = "/usr/lib/jvm/default-java"
54
+ node.default['java']['openjdk_packages'] = ["openjdk-#{node['java']['jdk_version']}-jdk"]
55
+ end
@@ -0,0 +1,44 @@
1
+ # Author:: Joshua Timberman (<joshua@opscode.com>)
2
+ # Cookbook Name:: java
3
+ # Recipe:: set_java_home
4
+ #
5
+ # Copyright 2013, Opscode, Inc.
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
+ ruby_block "set-env-java-home" do
20
+ block do
21
+ ENV["JAVA_HOME"] = node['java']['java_home']
22
+ end
23
+ not_if { ENV["JAVA_HOME"] == node['java']['java_home'] }
24
+ end
25
+
26
+ directory "/etc/profile.d" do
27
+ mode 00755
28
+ end
29
+
30
+ file "/etc/profile.d/jdk.sh" do
31
+ content "export JAVA_HOME=#{node['java']['java_home']}"
32
+ mode 00755
33
+ end
34
+
35
+ if node['java']['set_etc_environment']
36
+ ruby_block "Set JAVA_HOME in /etc/environment" do
37
+ block do
38
+ file = Chef::Util::FileEdit.new("/etc/environment")
39
+ file.insert_line_if_no_match(/^JAVA_HOME=/, "JAVA_HOME=#{node['java']['java_home']}")
40
+ file.search_file_replace_line(/^JAVA_HOME=/, "JAVA_HOME=#{node['java']['java_home']}")
41
+ file.write_file
42
+ end
43
+ end
44
+ end