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,60 @@
1
+ #!/usr/bin/env rake
2
+
3
+ # Style tests. Rubocop and Foodcritic
4
+ namespace :style do
5
+ begin
6
+ require 'rubocop/rake_task'
7
+ desc 'Run Ruby style checks'
8
+ RuboCop::RakeTask.new(:ruby)
9
+ rescue LoadError
10
+ puts '>>>>> Rubocop gem not loaded, omitting tasks' unless ENV['CI']
11
+ end
12
+
13
+ begin
14
+ require 'foodcritic'
15
+
16
+ desc 'Run Chef style checks'
17
+ FoodCritic::Rake::LintTask.new(:chef) do |t|
18
+ t.options = {
19
+ fail_tags: ['any']
20
+ }
21
+ end
22
+ rescue LoadError
23
+ puts '>>>>> foodcritic gem not loaded, omitting tasks' unless ENV['CI']
24
+ end
25
+ end
26
+
27
+ desc 'Run all style checks'
28
+ task style: ['style:chef', 'style:ruby']
29
+
30
+ namespace :unit do
31
+ begin
32
+ require 'rspec/core/rake_task'
33
+ desc 'Runs specs with chefspec.'
34
+ RSpec::Core::RakeTask.new(:rspec)
35
+ rescue LoadError
36
+ puts '>>>>> chefspec gem not loaded, omitting tasks' unless ENV['CI']
37
+ end
38
+ end
39
+
40
+ desc 'Run all unit tests'
41
+ task unit: ['unit:rspec']
42
+
43
+ # Integration tests. Kitchen.ci
44
+ namespace :integration do
45
+ begin
46
+ require 'kitchen/rake_tasks'
47
+
48
+ desc 'Run kitchen integration tests'
49
+ Kitchen::RakeTasks.new
50
+ rescue LoadError
51
+ puts '>>>>> Kitchen gem not loaded, omitting tasks' unless ENV['CI']
52
+ end
53
+ end
54
+
55
+ desc 'Run all tests on Travis'
56
+ task travis: ['unit']
57
+
58
+ # Default
59
+ # task default: ['unit', 'style', 'integration:kitchen:all']
60
+ task default: ['unit', 'style', 'integration:kitchen:all']
@@ -0,0 +1,41 @@
1
+ Testing the java cookbook
2
+ =====
3
+
4
+ This cookbook includes both unit tests via [ChefSpec](https://github.com/sethvargo/chefspec) and integration tests via [Test Kitchen](https://github.com/test-kitchen/test-kitchen). Contributions to this cookbook will only be accepted if all tests pass successfully:
5
+
6
+ ```bash
7
+ kitchen test
8
+ chef exec rspec
9
+ ```
10
+
11
+ Setting up the test environment
12
+ -----
13
+
14
+ Install the latest version of [Vagrant](http://www.vagrantup.com/downloads.html) and [VirtualBox](https://www.virtualbox.org/wiki/Downloads) (free) or [VMWare Fusion](http://www.vmware.com/products/fusion) (paid).
15
+
16
+ The Chef tooling (chefspec/test kitchen/etc) is managed by the [Chef Development Kit](http://downloads.getchef.com/chef-dk/) - Version 0.3.4
17
+
18
+ Clone the latest version of the cookbook from the repository.
19
+
20
+ ```bash
21
+ git clone git@github.com:agileorbit-cookbooks/java.git
22
+ cd java
23
+ ```
24
+
25
+ Running ChefSpec
26
+ -----
27
+
28
+ ChefSpec unit tests are located in `spec`. Each recipe has a `recipename_spec.rb` file that contains unit tests for that recipe. Your new functionality or bug fix should have corresponding test coverage - if it's a change, make sure it doesn't introduce a regression (existing tests should pass). If it's a change or introduction of new functionality, add new tests as appropriate.
29
+
30
+ To run ChefSpec for the whole cookbook:
31
+
32
+ `chef exec rspec`
33
+
34
+ To run ChefSpec for a specific recipe:
35
+
36
+ `chef exec rspec spec/set_java_home_spec.rb`
37
+
38
+ Running Test Kitchen
39
+ -----
40
+
41
+ Test Kitchen test suites are defined in [.kitchen.yml](https://github.com/agileorbit-cookbooks/java/blob/master/.kitchen.yml). Running `kitchen test` will cause Test Kitchen to spin up each platform VM in turn, running the `java::default` recipe with differing parameters in order to test all possible combinations of platform, install_flavor, and JDK version. If the Chef run completes successfully, corresponding tests in `test/integration` are executed. These must also pass.
@@ -0,0 +1,146 @@
1
+ #
2
+ # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
+ # Cookbook Name:: java
4
+ # Attributes:: default
5
+ #
6
+ # Copyright 2010, 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
+ # default jdk attributes
21
+ default['java']['jdk_version'] = '6'
22
+ default['java']['arch'] = kernel['machine'] =~ /x86_64/ ? "x86_64" : "i586"
23
+ default['java']['openjdk_packages'] = []
24
+ default['java']['openjdk_version'] = nil
25
+ default['java']['accept_license_agreement'] = false
26
+ default['java']['set_default'] = true
27
+ default['java']['alternatives_priority'] = 1062
28
+ default['java']['set_etc_environment'] = false
29
+ default['java']['use_alt_suffix'] = true
30
+ default['java']['reset_alternatives'] = true
31
+
32
+ # the following retry parameters apply when downloading oracle java
33
+ default['java']['ark_retries'] = 0
34
+ default['java']['ark_retry_delay'] = 2
35
+ default['java']['ark_timeout'] = 600
36
+
37
+ case node['platform_family']
38
+ when "windows"
39
+ default['java']['install_flavor'] = "windows"
40
+ default['java']['windows']['url'] = nil
41
+ default['java']['windows']['checksum'] = nil
42
+ default['java']['windows']['package_name'] = "Java(TM) SE Development Kit 7 (64-bit)"
43
+ when "mac_os_x"
44
+ default['java']['install_flavor'] = "homebrew"
45
+ else
46
+ default['java']['install_flavor'] = "openjdk"
47
+ end
48
+
49
+ case node['java']['install_flavor']
50
+ when 'ibm', 'ibm_tar'
51
+ default['java']['ibm']['url'] = nil
52
+ default['java']['ibm']['checksum'] = nil
53
+ default['java']['ibm']['accept_ibm_download_terms'] = false
54
+ default['java']['java_home'] = "/opt/ibm/java"
55
+
56
+ default['java']['ibm']['6']['bin_cmds'] = [ "appletviewer", "apt", "ControlPanel", "extcheck", "HtmlConverter", "idlj", "jar", "jarsigner",
57
+ "java", "javac", "javadoc", "javah", "javap", "javaws", "jconsole", "jcontrol", "jdb", "jdmpview",
58
+ "jrunscript", "keytool", "native2ascii", "policytool", "rmic", "rmid", "rmiregistry",
59
+ "schemagen", "serialver", "tnameserv", "wsgen", "wsimport", "xjc" ]
60
+
61
+ default['java']['ibm']['7']['bin_cmds'] = node['java']['ibm']['6']['bin_cmds'] + [ "pack200", "unpack200" ]
62
+ when 'oracle_rpm'
63
+ # type of java RPM : jdk or jre
64
+ default['java']['oracle_rpm']['type'] = 'jdk'
65
+
66
+ # optional, can be overriden to pin to a version different
67
+ # from the up-to-date.
68
+ default['java']['oracle_rpm']['package_version'] = nil
69
+
70
+ # optional, some distros re-package the official Oracle's RPM
71
+ # with a different name
72
+ default['java']['oracle_rpm']['package_name'] = nil
73
+
74
+ # set the JAVA_HOME path, it may be overriden
75
+ # when a package version is provided.
76
+ default['java']['java_home'] = "/usr/java/latest"
77
+ end
78
+
79
+ # if you change this to true, you can download directly from Oracle
80
+ default['java']['oracle']['accept_oracle_download_terms'] = false
81
+
82
+ # direct download paths for oracle, you have been warned!
83
+
84
+ # jdk6 attributes
85
+ default['java']['jdk']['6']['bin_cmds'] = [ "appletviewer", "apt", "ControlPanel", "extcheck", "HtmlConverter", "idlj", "jar", "jarsigner",
86
+ "java", "javac", "javadoc", "javah", "javap", "javaws", "jconsole", "jcontrol", "jdb", "jhat",
87
+ "jinfo", "jmap", "jps", "jrunscript", "jsadebugd", "jstack", "jstat", "jstatd", "jvisualvm",
88
+ "keytool", "native2ascii", "orbd", "pack200", "policytool", "rmic", "rmid", "rmiregistry",
89
+ "schemagen", "serialver", "servertool", "tnameserv", "unpack200", "wsgen", "wsimport", "xjc"]
90
+
91
+ # x86_64
92
+ default['java']['jdk']['6']['x86_64']['url'] = 'http://download.oracle.com/otn-pub/java/jdk/6u45-b06/jdk-6u45-linux-x64.bin'
93
+ default['java']['jdk']['6']['x86_64']['checksum'] = '6b493aeab16c940cae9e3d07ad2a5c5684fb49cf06c5d44c400c7993db0d12e8'
94
+
95
+ # i586
96
+ default['java']['jdk']['6']['i586']['url'] = 'http://download.oracle.com/otn-pub/java/jdk/6u45-b06/jdk-6u45-linux-i586.bin'
97
+ default['java']['jdk']['6']['i586']['checksum'] = 'd53b5a2518d80e1d95565f0adda54eee229dc5f4a1d1a3c2f7bf5045b168a357'
98
+
99
+ # jdk7 attributes
100
+
101
+ default['java']['jdk']['7']['bin_cmds'] = [ "appletviewer", "apt", "ControlPanel", "extcheck", "idlj", "jar", "jarsigner", "java", "javac",
102
+ "javadoc", "javafxpackager", "javah", "javap", "javaws", "jcmd", "jconsole", "jcontrol", "jdb",
103
+ "jhat", "jinfo", "jmap", "jps", "jrunscript", "jsadebugd", "jstack", "jstat", "jstatd", "jvisualvm",
104
+ "keytool", "native2ascii", "orbd", "pack200", "policytool", "rmic", "rmid", "rmiregistry",
105
+ "schemagen", "serialver", "servertool", "tnameserv", "unpack200", "wsgen", "wsimport", "xjc"]
106
+
107
+ # Oracle doesn't seem to publish SHA256 checksums for Java releases, so we use MD5 instead.
108
+ # Official checksums for the latest release can be found at https://www.oracle.com/webfolder/s/digest/7u75checksum.html
109
+
110
+ # x86_64
111
+ default['java']['jdk']['7']['x86_64']['url'] = 'http://download.oracle.com/otn-pub/java/jdk/7u75-b13/jdk-7u75-linux-x64.tar.gz'
112
+ default['java']['jdk']['7']['x86_64']['checksum'] = '6f1f81030a34f7a9c987f8b68a24d139'
113
+
114
+ # i586
115
+ default['java']['jdk']['7']['i586']['url'] = 'http://download.oracle.com/otn-pub/java/jdk/7u75-b13/jdk-7u75-linux-i586.tar.gz'
116
+ default['java']['jdk']['7']['i586']['checksum'] = 'e4371a4fddc049eca3bfef293d812b8e'
117
+
118
+ # jdk8 attributes
119
+
120
+ default['java']['jdk']['8']['bin_cmds'] = [ "appletviewer", "apt", "ControlPanel", "extcheck", "idlj", "jar", "jarsigner", "java", "javac",
121
+ "javadoc", "javafxpackager", "javah", "javap", "javaws", "jcmd", "jconsole", "jcontrol", "jdb",
122
+ "jdeps", "jhat", "jinfo", "jjs", "jmap", "jmc", "jps", "jrunscript", "jsadebugd", "jstack",
123
+ "jstat", "jstatd", "jvisualvm", "keytool", "native2ascii", "orbd", "pack200", "policytool",
124
+ "rmic", "rmid", "rmiregistry", "schemagen", "serialver", "servertool", "tnameserv",
125
+ "unpack200", "wsgen", "wsimport", "xjc"]
126
+
127
+ # Oracle just started publishing SHA256 checksums for Java releases with 8u51, so we use MD5 instead.
128
+ # Official checksums for the latest release can be found at https://www.oracle.com/webfolder/s/digest/8u51checksum.html
129
+
130
+ # x86_64
131
+ default['java']['jdk']['8']['x86_64']['url'] = 'http://download.oracle.com/otn-pub/java/jdk/8u51-b16/jdk-8u51-linux-x64.tar.gz'
132
+ default['java']['jdk']['8']['x86_64']['checksum'] = 'b34ff02c5d98b6f372288c17e96c51cf'
133
+
134
+ # i586
135
+ default['java']['jdk']['8']['i586']['url'] = 'http://download.oracle.com/otn-pub/java/jdk/8u51-b16/jdk-8u51-linux-i586.tar.gz'
136
+ default['java']['jdk']['8']['i586']['checksum'] = '742b9151d9190a9ae7d8ed05c7d39850'
137
+
138
+
139
+ default['java']['oracle']['jce']['enabled'] = false
140
+ default['java']['oracle']['jce']['8']['url'] = 'http://download.oracle.com/otn-pub/java/jce/8/jce_policy-8.zip'
141
+ default['java']['oracle']['jce']['8']['checksum'] = 'f3020a3922efd6626c2fff45695d527f34a8020e938a49292561f18ad1320b59'
142
+ default['java']['oracle']['jce']['7']['url'] = 'http://download.oracle.com/otn-pub/java/jce/7/UnlimitedJCEPolicyJDK7.zip'
143
+ default['java']['oracle']['jce']['7']['checksum'] = '7a8d790e7bd9c2f82a83baddfae765797a4a56ea603c9150c87b7cdb7800194d'
144
+ default['java']['oracle']['jce']['6']['url'] = 'http://download.oracle.com/otn-pub/java/jce_policy/6/jce_policy-6.zip'
145
+ default['java']['oracle']['jce']['6']['checksum'] = 'd0c2258c3364120b4dbf7dd1655c967eee7057ac6ae6334b5ea8ceb8bafb9262'
146
+ default['java']['oracle']['jce']['home'] = '/opt/java_jce'
@@ -0,0 +1,120 @@
1
+ #
2
+ # Author:: Joshua Timberman <joshua@opscode.com>
3
+ # Copyright:: Copyright (c) 2013, Opscode, Inc. <legal@opscode.com>
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require 'chef/version_constraint'
19
+ require 'uri'
20
+ require 'pathname'
21
+
22
+ module Opscode
23
+ class OpenJDK
24
+
25
+ attr_accessor :java_home, :jdk_version
26
+
27
+ def initialize(node)
28
+ @node = node.to_hash
29
+ @java_home = @node['java']['java_home'] || '/usr/lib/jvm/default-java'
30
+ @jdk_version = @node['java']['jdk_version'].to_s || '6'
31
+ end
32
+
33
+ def java_location
34
+ File.join(java_home_parent(@java_home), openjdk_path, 'bin/java')
35
+ end
36
+
37
+ def alternatives_priority
38
+ if @jdk_version == '6'
39
+ # 'accepted' default for java 6
40
+ 1061
41
+ elsif @jdk_version == '7'
42
+ # i just made this number up
43
+ 1100
44
+ elsif @jdk_version.to_i > 7
45
+ # just a guard against the incoming java 8
46
+ # so this cookbook will actually work for.. new versions of java
47
+ 1110
48
+ else
49
+ # it's not 6, it's not 7, it's not newer than
50
+ # 7, but we probably want to install it, so
51
+ # override 6's priority. arbitrary number.
52
+ 1062
53
+ end
54
+ end
55
+
56
+ def java_home_parent(java_home)
57
+ Pathname.new(java_home).parent.to_s
58
+ end
59
+
60
+ def openjdk_path
61
+ case @node['platform_family']
62
+ when 'debian'
63
+ 'java-%s-openjdk%s/jre' % [@jdk_version, arch_dir]
64
+ when 'rhel', 'fedora'
65
+ 'jre-1.%s.0-openjdk%s' % [@jdk_version, arch_dir]
66
+ when 'smartos'
67
+ 'jre'
68
+ else
69
+ 'jre'
70
+ end
71
+ end
72
+
73
+ def arch_dir
74
+ @node['kernel']['machine'] == 'x86_64' ? sixty_four : thirty_two
75
+ end
76
+
77
+ def sixty_four
78
+ case @node['platform_family']
79
+ when 'debian'
80
+ old_version? ? '' : '-amd64'
81
+ when 'rhel', 'fedora'
82
+ '.x86_64'
83
+ else
84
+ '-x86_64'
85
+ end
86
+ end
87
+
88
+ def thirty_two
89
+ case @node['platform_family']
90
+ when 'debian'
91
+ old_version? ? '' : '-i386'
92
+ else
93
+ ''
94
+ end
95
+ end
96
+
97
+ # This method is used above (#sixty_four, #thirty_two) so we know
98
+ # whether to specify the architecture as part of the path name.
99
+ def old_version?
100
+ case @node['platform']
101
+ when 'ubuntu'
102
+ Chef::VersionConstraint.new("< 11.0").include?(@node['platform_version'])
103
+ when 'debian'
104
+ Chef::VersionConstraint.new("< 7.0").include?(@node['platform_version'])
105
+ end
106
+ end
107
+ end
108
+ end
109
+
110
+ class Chef
111
+ class Recipe
112
+ def valid_ibm_jdk_uri?(url)
113
+ url =~ ::URI::ABS_URI && %w[file http https].include?(::URI.parse(url).scheme)
114
+ end
115
+
116
+ def platform_requires_license_acceptance?
117
+ %w(smartos).include?(node.platform)
118
+ end
119
+ end
120
+ end
@@ -0,0 +1,5 @@
1
+ if defined?(ChefSpec)
2
+ def set_java_alternatives(resource_name)
3
+ ChefSpec::Matchers::ResourceMatcher.new(:java_alternatives, :set, resource_name)
4
+ end
5
+ end
@@ -0,0 +1,69 @@
1
+ {
2
+ "name": "java",
3
+ "description": "Installs Java runtime.",
4
+ "long_description": "java\n=====\n\nThis cookbook installs a Java JDK/JRE. It defaults to installing\nOpenJDK, but it can also install Oracle and IBM JDKs.\n\nUsage\n-----\n\nSimply include the `java` recipe wherever you would like Java installed, such as a run list (`recipe[java]`) or a cookbook (`include_recipe 'java'`). By default, OpenJDK 6 is installed. The `install_flavor` attribute is used to determine which JDK to install (OpenJDK, Oracle, IBM, or Windows), and `jdk_version` specifies which version to install (currently 6 and 7 are supported for all JDK types, 8 for Oracle only).\n\n### Examples\n\nTo install Oracle Java 7 (note that when installing Oracle JDK, `accept_oracle_download_terms` attribute must be set -- see below role for an example):\n```ruby\nname \"java\"\ndescription \"Install Oracle Java\"\ndefault_attributes(\n \"java\" => {\n \"install_flavor\" => \"oracle\",\n \"jdk_version\" => \"7\",\n \"oracle\" => {\n \"accept_oracle_download_terms\" => true\n }\n }\n)\nrun_list(\n \"recipe[java]\"\n)\n```\n\nExample role to install IBM flavored Java:\n```ruby\nname \"java\"\ndescription \"Install IBM Java on Ubuntu\"\ndefault_attributes(\n \"java\" => {\n \"install_flavor\" => \"ibm\",\n \"ibm\" => {\n \"accept_ibm_download_terms\" => true,\n \"url\" => \"http://fileserver.example.com/ibm-java-x86_64-sdk-7.0-4.1.bin\",\n \"checksum\" => \"The SHA256 checksum of the bin\"\n }\n }\n)\nrun_list(\n \"recipe[java]\"\n)\n```\n\nRequirements\n-----\n\nChef 0.10.10+ and Ohai 6.10+ for `platform_family` use.\n\n### Platform\n\n* Debian, Ubuntu\n* CentOS, Red Hat, Fedora, Scientific, Amazon, XenServer\n* ArchLinux\n* FreeBSD\n* SmartOS\n* Windows\n* Mac OS X\n\nAttributes\n-----\n\nSee `attributes/default.rb` for default values.\n\n* `node['java']['install_flavor']` - Flavor of JVM you would like\ninstalled (`oracle`, `oracle_rpm`, `openjdk`, `ibm`, `windows`), default `openjdk`\non Linux/Unix platforms, `windows` on Windows platforms.\n* `node['java']['jdk_version']` - JDK version to install, defaults to\n `'6'`.\n* `node['java']['java_home']` - Default location of the\n \"`$JAVA_HOME`\".\n* `node['java']['set_etc_environment']` - Optionally sets\n JAVA_HOME in `/etc/environment` for Default `false`.\n* `node['java']['openjdk_packages']` - Array of OpenJDK package names\n to install in the `java::openjdk` recipe. This is set based on the\n platform.\n* `node['java']['tarball']` - Name of the tarball to retrieve from\nyour internal repository, default `jdk1.6.0_29_i386.tar.gz`\n* `node['java']['tarball_checksum']` - Checksum for the tarball, if\nyou use a different tarball, you also need to create a new sha256\nchecksum\n* `node['java']['jdk']` - Version and architecture specific attributes\nfor setting the URL on Oracle's site for the JDK, and the checksum of\nthe .tar.gz.\n* `node['java']['oracle']['accept_oracle_download_terms']` - Indicates\n that you accept Oracle's EULA\n* `node['java']['windows']['url']` - The internal location of your\n java install for windows\n* `node['java']['windows']['package_name']` - The package name used by\n windows_package to check in the registry to determine if the install\n has already been run\n* `node['java']['windows']['checksum']` - The checksum for the package to\n download on Windows machines (default is nil, which does not perform\n checksum validation)\n* `node['java']['ibm']['url']` - The URL which to download the IBM\n JDK/SDK. See the `ibm` recipe section below.\n* `node['java']['ibm']['accept_ibm_download_terms']` - Indicates that\n you accept IBM's EULA (for `java::ibm`)\n* `node['java']['oracle_rpm']['type']` - Type of java RPM (`jre` or `jdk`), default `jdk`\n* `node['java']['oracle_rpm']['package_version']` - optional, can be set \n to pin a version different from the up-to-date one available in the YUM repo,\n it might be needed to also override the node['java']['java_home'] attribute \n to a value consistent with the defined version\n* `node['java']['oracle_rpm']['package_name']` - optional, can be set \n to define a package name different from the RPM published by Oracle.\n* `node['java']['accept_license_agreement']` - Indicates that you accept\n the EULA for openjdk package installation.\n* `node['java']['set_default']` - Indicates whether or not you want the\n JDK installed to be default on the system. Defaults to true.\n* `node['java']['oracle']['jce']['enabled']` - Indicates if the JCE Unlimited Strength Jurisdiction Policy Files should be installed for oracle JDKs\n* `node['java']['oracle']['jce']['home']` - Where the JCE policy files should be installed to\n* `node['java']['oracle']['jce'][java_version]['checksum']` - Checksum of the JCE policy zip. Can be sha256 or md5\n* `node['java']['oracle']['jce'][java_version]['url']` - URL which to download the JCE policy zip\n\nRecipes\n-----\n\n### default\n\nInclude the default recipe in a run list or recipe to get `java`. By default\nthe `openjdk` flavor of Java is installed, but this can be changed by\nusing the `install_flavor` attribute. By default on Windows platform\nsystems, the `install_flavor` is `windows` and on Mac OS X platform systems, the `install_flavor` is `homebrew`.\n\nOpenJDK is the default because of licensing changes made upstream by\nOracle. See notes on the `oracle` recipe below.\n\nNOTE: In most cases, including just the default recipe will be sufficient.\nIt's possible to include the install_type recipes directly, as long as\nthe necessary attributes (such as java_home) are set.\n\n### set_attributes_from_version\n\nSets default attributes based on the JDK version. This is included by `default.rb`. This logic must be in\na recipe instead of attributes/default.rb. See [#95](https://github.com/agileorbit-cookbooks/java/pull/95)\nfor details.\n\n### default_java_symlink\n\nUpdates /usr/lib/jvm/default-java to point to JAVA_HOME.\n\n### purge_packages\n\nPurges deprecated Sun Java packages.\n\n### openjdk\n\nThis recipe installs the `openjdk` flavor of Java. It also uses the\n`alternatives` system on RHEL/Debian families to set the default Java.\n\nOn platforms such as SmartOS that require the acceptance of a license\nagreement during package installation, set\n`node['java']['accept_license_agreement']` to true in order to indicate\nthat you accept the license.\n\n### oracle\n\nThis recipe installs the `oracle` flavor of Java. This recipe does not\nuse distribution packages as Oracle changed the licensing terms with\nJDK 1.6u27 and prohibited the practice for both RHEL and Debian family\nplatforms.\n\nAs of 26 March 2012 you can no longer directly download the JDK from\nOracle's website without using a special cookie. This cookbook uses\nthat cookie to download the oracle recipe on your behalf, however the\n`java::oracle` recipe forces you to set either override the\n`node['java']['oracle']['accept_oracle_download_terms']` to true or\nset up a private repository accessible by HTTP.\n\noverride the `accept_oracle_download_terms` in, e.g., `roles/base.rb`\n```ruby\n default_attributes(\n :java => {\n :oracle => {\n \"accept_oracle_download_terms\" => true\n }\n }\n )\n```\n\nFor both RHEL and Debian families, this recipe pulls the binary\ndistribution from the Oracle website, and installs it in the default\n`JAVA_HOME` for each distribution. For Debian, this is\n`/usr/lib/jvm/default-java`. For RHEl, this is `/usr/lib/jvm/java`.\n\nAfter putting the binaries in place, the `java::oracle` recipe updates\n`/usr/bin/java` to point to the installed JDK using the\n`update-alternatives` script. This is all handled in the `java_ark`\nLWRP.\n\n### oracle_i386\n\nThis recipe installs the 32-bit Java virtual machine without setting\nit as the default. This can be useful if you have applications on the\nsame machine that require different versions of the JVM.\n\nThis recipe operates in a similar manner to `java::oracle`.\n\n### oracle_rpm\n\nThis recipe installs the Oracle JRE or JDK provided by a custom YUM\nrepositories.\nIt also uses the `alternatives` system on RHEL families to set\nthe default Java.\n\n### windows\n\nBecause there is no easy way to pull the java msi off oracle's site,\nthis recipe requires you to host it internally on your own http repo.\n\n**IMPORTANT NOTE**\n\nIf you use the `windows` recipe, you'll need to make sure you've uploaded\nthe `aws` and `windows` cookbooks. As of version 1.18.0, this cookbook\nreferences them with `suggests` instead of `depends`, as they are only\nused by the `windows` recipe.\n\n### ibm\n\nThe `java::ibm` recipe is used to install the IBM version of Java.\nNote that IBM requires you to create an account *and* log in to\ndownload the binary installer for your platform. You must accept the\nlicense agreement with IBM to use their version of Java. In this\ncookbook, you indicate this by setting\n`node['java']['ibm']['accept_ibm_download_terms']` to `true`. You must\nalso host the binary on your own HTTP server to have an automated\ninstallation. The `node['java']['ibm']['url']` attribute must be set\nto a valid https/http URL; the URL is checked for validity in the recipe.\n\nAt this time the `java::ibm` recipe does not support multiple SDK\ninstallations.\n\nResources/Providers\n-----\n\n### java_ark\n\nThis cookbook contains the `java_ark` LWRP. Generally speaking this\nLWRP is deprecated in favor of `ark` from the\n[ark cookbook](https://github.com/opscode-cookbooks/ark), but it is\nstill used in this cookbook for handling the Oracle JDK installation.\n\nBy default, the extracted directory is extracted to\n`app_root/extracted_dir_name` and symlinked to `app_root/default`\n\n#### Actions\n\n- `:install`: extracts the tarball and makes necessary symlinks\n- `:remove`: removes the tarball and run update-alternatives for all\n symlinked `bin_cmds`\n\n#### Attribute Parameters\n\n- `url`: path to tarball, .tar.gz, .bin (oracle-specific), and .zip\n currently supported\n- `checksum`: SHA256 checksum, not used for security but avoid\n redownloading the archive on each chef-client run\n- `app_home`: the default for installations of this type of\n application, for example, `/usr/lib/tomcat/default`. If your\n application is not set to the default, it will be placed at the same\n level in the directory hierarchy but the directory name will be\n `app_root/extracted_directory_name + \"_alt\"`\n- `app_home_mode`: file mode for app_home, is an integer\n- `bin_cmds`: array of binary commands that should be symlinked to\n `/usr/bin`, examples are mvn, java, javac, etc. These cmds must be in\n the `bin` subdirectory of the extracted folder. Will be ignored if this\n `java_ark` is not the default\n- `owner`: owner of extracted directory, set to \"root\" by default\n- `group`: group of extracted directory, set to `:owner` by default\n- `default`: whether this the default installation of this package,\n boolean true or false\n- `reset_alternatives`: whether alternatives is reset\n boolean true or false\n- `use_alt_suffix`: whether '_alt' suffix is used for not default javas\n boolean true or false\n\n#### Examples\n```ruby\n# install jdk6 from Oracle\njava_ark \"jdk\" do\n url 'http://download.oracle.com/otn-pub/java/jdk/6u29-b11/jdk-6u29-linux-x64.bin'\n checksum 'a8603fa62045ce2164b26f7c04859cd548ffe0e33bfc979d9fa73df42e3b3365'\n app_home '/usr/local/java/default'\n bin_cmds [\"java\", \"javac\"]\n action :install\nend\n```\n### java_alternatives\n\nThe `java_alternatives` LWRP uses `update-alternatives` command\nto set and unset command alternatives for various Java tools\nsuch as java, javac, etc.\n\n#### Actions\n\n- `:set`: set alternatives for Java tools\n- `:unset`: unset alternatives for Java tools\n\n#### Attribute Parameters\n\n- `java_location`: Java installation location.\n- `bin_cmds`: array of Java tool names to set or unset alternatives on.\n- `default`: whether to set the Java tools as system default. Boolean, defaults to `true`.\n- `priority`: priority of the alternatives. Integer, defaults to `1061`.\n\n#### Examples\n```ruby\n# set alternatives for java and javac commands\njava_alternatives \"set java alternatives\" do\n java_location '/usr/local/java'\n bin_cmds [\"java\", \"javac\"]\n action :set\nend\n```\n\nProduction Deployment with Oracle Java\n-----\nOracle has been known to change the behavior of its download site frequently. It is recommended you store the archives on an artifact server or s3 bucket. You can then override the attributes in a cookbook, role, or environment:\n\n```ruby\ndefault['java']['jdk_version'] = '7'\ndefault['java']['install_flavor'] = 'oracle'\ndefault['java']['jdk']['7']['x86_64']['url'] = 'http://artifactory.example.com/artifacts/jdk-7u65-linux-x64.tar.gz'\ndefault['java']['oracle']['accept_oracle_download_terms'] = true\n```\n\nRecommendations for inclusion in community cookbooks\n-----\n\nThis cookbook is a dependency for many other cookbooks in the Java/Chef sphere. Here are some guidelines for including it into other cookbooks:\n\n### Allow people to not use this cookbook\nMany users manage Java on their own or have systems that already have java installed. Give these users an option to skip this cookbook, for example:\n```ruby\ninclude_recipe 'java' if node['maven']['install_java']\n```\n\nThis would allow a users of the maven cookbook to choose if they want the maven cookbook to install java for them or leave that up to the consumer.\n\nAnother good example is from the [Jenkins Cookbook Java recipe](https://github.com/opscode-cookbooks/jenkins/commit/ca2a69d982011dc1bec6a6d0ee4da5c1a1599864).\n\n### Pinning to major version of cookbook and Java\nThis cookbook follows semver. It is recommended to pin at the major version of this cookbook when including it in other cookbooks, eg: `depends 'java', '~> 1.0'`\n\nIt is acceptable to set the `node['java']['jdk_version']` to a specific version if required for your software to run, eg software xyz requires Java 8 to run. Refrain from pinning to specific patches of the JDK to allow users to consume security updates.\n\nDevelopment\n-----\n\nThis cookbook uses\n[test-kitchen](https://github.com/opscode/test-kitchen) for\nintegration tests and\n[ChefSpec/RSpec](https://github.com/sethvargo/chefspec) for unit tests.\nSee [TESTING.md](https://github.com/agileorbit-cookbooks/java/blob/master/TESTING.md) for testing instructions.\n\nAt this time due to licensing concerns, the IBM recipe is not set up\nin test kitchen. If you would like to test this locally, copy\n.kitchen.yml to .kitchen.local.yml and add the following suite:\n```yml\nsuites:\n- name: ibm\n run_list: [\"recipe[java]\"]\n attributes:\n java:\n install_flavor: \"ibm\"\n ibm:\n accept_ibm_download_terms: true\n url: \"http://jenkins/ibm-java-x86_64-sdk-7.0-4.1.bin\"\n checksum: the-sha256-checksum\n```\n\nLog into the IBM DeveloperWorks site to download a copy of the IBM\nJava SDK you wish to use/test, host it on an internal HTTP server, and\ncalculate the SHA256 checksum to use in the suite.\n\nLicense and Author\n-----\n\n* Author: Seth Chisamore (<schisamo@opscode.com>)\n* Author: Bryan W. Berry (<bryan.berry@gmail.com>)\n* Author: Joshua Timberman (<joshua@opscode.com>)\n* Author: Eric Helgeson (<erichelgeson@gmail.com>)\n\nCopyright: 2014, Agile Orbit, LLC\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n",
5
+ "maintainer": "Agile Orbit",
6
+ "maintainer_email": "info@agileorbit.com",
7
+ "license": "Apache 2.0",
8
+ "platforms": {
9
+ "debian": ">= 0.0.0",
10
+ "ubuntu": ">= 0.0.0",
11
+ "centos": ">= 0.0.0",
12
+ "redhat": ">= 0.0.0",
13
+ "scientific": ">= 0.0.0",
14
+ "fedora": ">= 0.0.0",
15
+ "amazon": ">= 0.0.0",
16
+ "arch": ">= 0.0.0",
17
+ "oracle": ">= 0.0.0",
18
+ "freebsd": ">= 0.0.0",
19
+ "windows": ">= 0.0.0",
20
+ "suse": ">= 0.0.0",
21
+ "xenserver": ">= 0.0.0",
22
+ "smartos": ">= 0.0.0",
23
+ "mac_os_x": ">= 0.0.0"
24
+ },
25
+ "dependencies": {
26
+
27
+ },
28
+ "recommendations": {
29
+
30
+ },
31
+ "suggestions": {
32
+ "homebrew": ">= 0.0.0",
33
+ "windows": ">= 0.0.0",
34
+ "aws": ">= 0.0.0"
35
+ },
36
+ "conflicting": {
37
+
38
+ },
39
+ "providing": {
40
+
41
+ },
42
+ "replacing": {
43
+
44
+ },
45
+ "attributes": {
46
+
47
+ },
48
+ "groupings": {
49
+
50
+ },
51
+ "recipes": {
52
+ "java::default": "Installs Java runtime",
53
+ "java::default_java_symlink": "Updates /usr/lib/jvm/default-java",
54
+ "java::ibm": "Installs the JDK for IBM",
55
+ "java::ibm_tar": "Installs the JDK for IBM from a tarball",
56
+ "java::openjdk": "Installs the OpenJDK flavor of Java",
57
+ "java::oracle": "Installs the Oracle flavor of Java",
58
+ "java::oracle_i386": "Installs the 32-bit jvm without setting it as the default",
59
+ "java::oracle_rpm": "Installs the Oracle RPM flavor of Java",
60
+ "java::purge_packages": "Purges old Sun JDK packages",
61
+ "java::set_attributes_from_version": "Sets various attributes that depend on jdk_version",
62
+ "java::set_java_home": "Sets the JAVA_HOME environment variable",
63
+ "java::windows": "Installs the JDK on Windows",
64
+ "java::homebrew": "Installs the JDK on Mac OS X via Homebrew"
65
+ },
66
+ "version": "1.35.0",
67
+ "source_url": "",
68
+ "issues_url": ""
69
+ }
@@ -0,0 +1,94 @@
1
+ #
2
+ # Cookbook Name:: java
3
+ # Provider:: alternatives
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ require 'chef/mixin/shell_out'
18
+ include Chef::Mixin::ShellOut
19
+
20
+ action :set do
21
+ if new_resource.bin_cmds
22
+ # I couldn't find a way to cleanly avoid repeating this variable declaration in both :set and :unset
23
+ alternatives_cmd = node['platform_family'] == 'rhel' ? 'alternatives' : 'update-alternatives'
24
+ new_resource.bin_cmds.each do |cmd|
25
+
26
+ bin_path = "/usr/bin/#{cmd}"
27
+ alt_path = "#{new_resource.java_location}/bin/#{cmd}"
28
+ priority = new_resource.priority
29
+
30
+ if !::File.exist?(alt_path)
31
+ Chef::Log.debug "Skipping setting alternative for #{cmd}. Command #{alt_path} does not exist."
32
+ next
33
+ end
34
+
35
+ alternative_exists_same_prio = shell_out("#{alternatives_cmd} --display #{cmd} | grep #{alt_path} | grep 'priority #{priority}$'").exitstatus == 0
36
+ alternative_exists = shell_out("#{alternatives_cmd} --display #{cmd} | grep #{alt_path}").exitstatus == 0
37
+ # remove alternative is prio is changed and install it with new prio
38
+ if alternative_exists and !alternative_exists_same_prio
39
+ description = "Removing alternative for #{cmd} with old prio"
40
+ converge_by(description) do
41
+ Chef::Log.debug "Removing alternative for #{cmd} with old priority"
42
+ remove_cmd = shell_out("#{alternatives_cmd} --remove #{cmd} #{alt_path}")
43
+ alternative_exists = false
44
+ unless remove_cmd.exitstatus == 0
45
+ Chef::Application.fatal!(%Q[ remove alternative failed ])
46
+ end
47
+ end
48
+ end
49
+ # install the alternative if needed
50
+ unless alternative_exists
51
+ description = "Add alternative for #{cmd}"
52
+ converge_by(description) do
53
+ Chef::Log.debug "Adding alternative for #{cmd}"
54
+ if new_resource.reset_alternatives
55
+ shell_out("rm /var/lib/alternatives/#{cmd}")
56
+ end
57
+ install_cmd = shell_out("#{alternatives_cmd} --install #{bin_path} #{cmd} #{alt_path} #{priority}")
58
+ unless install_cmd.exitstatus == 0
59
+ Chef::Application.fatal!(%Q[ install alternative failed ])
60
+ end
61
+ end
62
+ new_resource.updated_by_last_action(true)
63
+ end
64
+
65
+ # set the alternative if default
66
+ if new_resource.default
67
+ alternative_is_set = shell_out("#{alternatives_cmd} --display #{cmd} | grep \"link currently points to #{alt_path}\"").exitstatus == 0
68
+ unless alternative_is_set
69
+ description = "Set alternative for #{cmd}"
70
+ converge_by(description) do
71
+ Chef::Log.debug "Setting alternative for #{cmd}"
72
+ set_cmd = shell_out("#{alternatives_cmd} --set #{cmd} #{alt_path}")
73
+ unless set_cmd.exitstatus == 0
74
+ Chef::Application.fatal!(%Q[ set alternative failed ])
75
+ end
76
+ end
77
+ new_resource.updated_by_last_action(true)
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
83
+
84
+ action :unset do
85
+ # I couldn't find a way to cleanly avoid repeating this variable declaration in both :set and :unset
86
+ alternatives_cmd = node['platform_family'] == 'rhel' ? 'alternatives' : 'update-alternatives'
87
+ new_resource.bin_cmds.each do |cmd|
88
+ alt_path = "#{new_resource.java_location}/bin/#{cmd}"
89
+ cmd = shell_out("#{alternatives_cmd} --remove #{cmd} #{alt_path}")
90
+ if cmd.exitstatus == 0
91
+ new_resource.updated_by_last_action(true)
92
+ end
93
+ end
94
+ end