from-scratch 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.chef/knife.rb +6 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Berksfile +17 -0
- data/Berksfile.lock +19 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +58 -0
- data/Rakefile +6 -0
- data/Thorfile +5 -0
- data/bin/scratchify +6 -0
- data/chefignore +101 -0
- data/cookbooks/chef_gem/CHANGELOG.md +24 -0
- data/cookbooks/chef_gem/README.md +38 -0
- data/cookbooks/chef_gem/libraries/chef_gem.rb +72 -0
- data/cookbooks/chef_gem/metadata.json +29 -0
- data/cookbooks/chef_gem/recipes/default.rb +0 -0
- data/cookbooks/java/.gitignore +21 -0
- data/cookbooks/java/.kitchen.docker.yml +15 -0
- data/cookbooks/java/.kitchen.yml +126 -0
- data/cookbooks/java/.travis.yml +6 -0
- data/cookbooks/java/Berksfile +10 -0
- data/cookbooks/java/CHANGELOG.md +398 -0
- data/cookbooks/java/CONTRIBUTING.md +12 -0
- data/cookbooks/java/Gemfile +15 -0
- data/cookbooks/java/ISSUES.md +43 -0
- data/cookbooks/java/LICENSE +201 -0
- data/cookbooks/java/README.md +402 -0
- data/cookbooks/java/Rakefile +60 -0
- data/cookbooks/java/TESTING.md +41 -0
- data/cookbooks/java/attributes/default.rb +146 -0
- data/cookbooks/java/libraries/helpers.rb +120 -0
- data/cookbooks/java/libraries/matchers.rb +5 -0
- data/cookbooks/java/metadata.json +69 -0
- data/cookbooks/java/providers/alternatives.rb +94 -0
- data/cookbooks/java/providers/ark.rb +255 -0
- data/cookbooks/java/recipes/default.rb +22 -0
- data/cookbooks/java/recipes/default_java_symlink.rb +19 -0
- data/cookbooks/java/recipes/homebrew.rb +3 -0
- data/cookbooks/java/recipes/ibm.rb +76 -0
- data/cookbooks/java/recipes/ibm_tar.rb +70 -0
- data/cookbooks/java/recipes/openjdk.rb +74 -0
- data/cookbooks/java/recipes/oracle.rb +74 -0
- data/cookbooks/java/recipes/oracle_i386.rb +73 -0
- data/cookbooks/java/recipes/oracle_jce.rb +75 -0
- data/cookbooks/java/recipes/oracle_rpm.rb +60 -0
- data/cookbooks/java/recipes/purge_packages.rb +20 -0
- data/cookbooks/java/recipes/set_attributes_from_version.rb +55 -0
- data/cookbooks/java/recipes/set_java_home.rb +44 -0
- data/cookbooks/java/recipes/windows.rb +82 -0
- data/cookbooks/java/resources/alternatives.rb +30 -0
- data/cookbooks/java/resources/ark.rb +58 -0
- data/cookbooks/java/templates/default/ibm_jdk.installer.properties.erb +3 -0
- data/cookbooks/java/templates/default/oracle.jinfo.erb +6 -0
- data/cookbooks/rvm/.foodcritic +1 -0
- data/cookbooks/rvm/.gitignore +7 -0
- data/cookbooks/rvm/.kitchen.yml +66 -0
- data/cookbooks/rvm/.travis.yml +9 -0
- data/cookbooks/rvm/Berksfile +10 -0
- data/cookbooks/rvm/CHANGELOG.md +253 -0
- data/cookbooks/rvm/CODE_OF_CONDUCT.md +12 -0
- data/cookbooks/rvm/CONTRIBUTING.md +26 -0
- data/cookbooks/rvm/Gemfile +20 -0
- data/cookbooks/rvm/Guardfile +12 -0
- data/cookbooks/rvm/README.md +1459 -0
- data/cookbooks/rvm/Rakefile +18 -0
- data/cookbooks/rvm/attributes/.gitkeep +0 -0
- data/cookbooks/rvm/attributes/default.rb +68 -0
- data/cookbooks/rvm/attributes/gem_package.rb +23 -0
- data/cookbooks/rvm/attributes/vagrant.rb +23 -0
- data/cookbooks/rvm/libraries/chef_rvm_environment_helpers.rb +55 -0
- data/cookbooks/rvm/libraries/chef_rvm_gemset_helpers.rb +67 -0
- data/cookbooks/rvm/libraries/chef_rvm_recipe_helpers.rb +80 -0
- data/cookbooks/rvm/libraries/chef_rvm_ruby_helpers.rb +95 -0
- data/cookbooks/rvm/libraries/chef_rvm_set_helpers.rb +16 -0
- data/cookbooks/rvm/libraries/chef_rvm_shell_helpers.rb +57 -0
- data/cookbooks/rvm/libraries/chef_rvm_string_cache.rb +104 -0
- data/cookbooks/rvm/libraries/chef_rvm_string_helpers.rb +61 -0
- data/cookbooks/rvm/libraries/chef_rvm_version_helpers.rb +45 -0
- data/cookbooks/rvm/libraries/gem_package_monkeypatch.rb +34 -0
- data/cookbooks/rvm/libraries/provider_rvm_installation.rb +185 -0
- data/cookbooks/rvm/libraries/resource_rvm_installation.rb +103 -0
- data/cookbooks/rvm/libraries/rvm_chef_user_environment.rb +55 -0
- data/cookbooks/rvm/libraries/rvm_rubygems_package.rb +189 -0
- data/cookbooks/rvm/libraries/rvm_shell_chef_wrapper.rb +99 -0
- data/cookbooks/rvm/metadata.json +51 -0
- data/cookbooks/rvm/providers/default_ruby.rb +63 -0
- data/cookbooks/rvm/providers/environment.rb +78 -0
- data/cookbooks/rvm/providers/gemset.rb +118 -0
- data/cookbooks/rvm/providers/global_gem.rb +97 -0
- data/cookbooks/rvm/providers/ruby.rb +178 -0
- data/cookbooks/rvm/providers/shell.rb +121 -0
- data/cookbooks/rvm/providers/wrapper.rb +73 -0
- data/cookbooks/rvm/recipes/.gitkeep +0 -0
- data/cookbooks/rvm/recipes/default.rb +40 -0
- data/cookbooks/rvm/recipes/gem_package.rb +33 -0
- data/cookbooks/rvm/recipes/system.rb +37 -0
- data/cookbooks/rvm/recipes/system_install.rb +42 -0
- data/cookbooks/rvm/recipes/user.rb +43 -0
- data/cookbooks/rvm/recipes/user_install.rb +58 -0
- data/cookbooks/rvm/recipes/vagrant.rb +37 -0
- data/cookbooks/rvm/resources/default_ruby.rb +31 -0
- data/cookbooks/rvm/resources/environment.rb +31 -0
- data/cookbooks/rvm/resources/gem.rb +37 -0
- data/cookbooks/rvm/resources/gemset.rb +32 -0
- data/cookbooks/rvm/resources/global_gem.rb +34 -0
- data/cookbooks/rvm/resources/ruby.rb +32 -0
- data/cookbooks/rvm/resources/shell.rb +41 -0
- data/cookbooks/rvm/resources/wrapper.rb +34 -0
- data/cookbooks/rvm/templates/default/rvmrc.erb +14 -0
- data/cookbooks/rvm/templates/default/vagrant-chef-client-wrapper.erb +23 -0
- data/cookbooks/rvm/templates/default/vagrant-chef-solo-wrapper.erb +23 -0
- data/cookbooks/rvm/test/integration/data_bags/users/virgil1.json +4 -0
- data/cookbooks/rvm/test/integration/data_bags/users/virgil2.json +4 -0
- data/cookbooks/rvm/test/integration/data_bags/users/wigglebottom.json +3 -0
- data/cookbooks/rvm/test/integration/installs/bats/version_pinning.bats +13 -0
- data/cookbooks/rvm/test/integration/rubies/bats/_common.bash +16 -0
- data/cookbooks/rvm/test/integration/rubies/bats/verify_1.9.3.bats +9 -0
- data/cookbooks/rvm/test/integration/rubies/bats/verify_jruby.bats +12 -0
- data/cookbooks/rvm/test/integration/rubies/bats/verify_patch_support.bats +19 -0
- data/cookbooks/rvm/test/integration/rubies/bats/verify_ree.bats +9 -0
- data/cookbooks/rvm/test/integration/rubies/bats/verify_rubygems_version_support.bats +15 -0
- data/cookbooks/rvm/test/integration/stock_system_and_user/bats/system.bats +45 -0
- data/cookbooks/rvm/test/unit/libraries/provider_rvm_installation_spec.rb +220 -0
- data/cookbooks/rvm/test/unit/libraries/resource_rvm_installation_spec.rb +139 -0
- data/cookbooks/rvm/test/unit/spec_helper.rb +23 -0
- data/cookbooks/scratchify/.chef/knife.rb +9 -0
- data/cookbooks/scratchify/Berksfile +16 -0
- data/cookbooks/scratchify/Berksfile.lock +19 -0
- data/cookbooks/scratchify/LICENSE.txt +21 -0
- data/cookbooks/scratchify/README.md +41 -0
- data/cookbooks/scratchify/Thorfile +5 -0
- data/cookbooks/scratchify/bin/console +14 -0
- data/cookbooks/scratchify/bin/scratchify +6 -0
- data/cookbooks/scratchify/bin/setup +7 -0
- data/cookbooks/scratchify/chefignore +101 -0
- data/cookbooks/scratchify/data_bags/users/deploy.json +6 -0
- data/cookbooks/scratchify/environments/.gitkeep +0 -0
- data/cookbooks/scratchify/from-scratch.gemspec +36 -0
- data/cookbooks/scratchify/lib/from/scratch.rb +31 -0
- data/cookbooks/scratchify/lib/from/scratch/interviewer.rb +35 -0
- data/cookbooks/scratchify/lib/from/scratch/version.rb +3 -0
- data/cookbooks/scratchify/metadata.json +36 -0
- data/cookbooks/scratchify/nodes/normfood.ru.json +75 -0
- data/cookbooks/scratchify/recipes/default.rb +0 -0
- data/cookbooks/scratchify/roles/.gitkeep +0 -0
- data/cookbooks/scratchify/spec/from/scratch_spec.rb +11 -0
- data/cookbooks/scratchify/spec/spec_helper.rb +2 -0
- data/cookbooks/user/.gitignore +5 -0
- data/cookbooks/user/.kitchen.yml +46 -0
- data/cookbooks/user/.travis.yml +4 -0
- data/cookbooks/user/Berksfile +7 -0
- data/cookbooks/user/CHANGELOG.md +101 -0
- data/cookbooks/user/Gemfile +14 -0
- data/cookbooks/user/README.md +447 -0
- data/cookbooks/user/Rakefile +21 -0
- data/cookbooks/user/attributes/default.rb +50 -0
- data/cookbooks/user/libraries/matchers.rb +26 -0
- data/cookbooks/user/metadata.json +46 -0
- data/cookbooks/user/providers/account.rb +212 -0
- data/cookbooks/user/recipes/data_bag.rb +59 -0
- data/cookbooks/user/recipes/default.rb +18 -0
- data/cookbooks/user/resources/account.rb +41 -0
- data/cookbooks/user/templates/default/authorized_keys.erb +7 -0
- data/from-scratch.gemspec +33 -0
- data/lib/from-scratch.rb +25 -0
- data/lib/from-scratch/version.rb +3 -0
- data/metadata.rb +15 -0
- data/recipes/default.rb +0 -0
- data/templates/node.json.erb +31 -0
- data/templates/user.json.erb +6 -0
- metadata +330 -0
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Author:: Bryan W. Berry (<bryan.berry@gmail.com>)
|
|
3
|
+
# Cookbook Name:: java
|
|
4
|
+
# Provider:: ark
|
|
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
|
+
require 'chef/mixin/shell_out'
|
|
21
|
+
include Chef::Mixin::ShellOut
|
|
22
|
+
|
|
23
|
+
def whyrun_supported?
|
|
24
|
+
true
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def parse_app_dir_name url
|
|
28
|
+
file_name = url.split('/')[-1]
|
|
29
|
+
# funky logic to parse oracle's non-standard naming convention
|
|
30
|
+
# for jdk1.6
|
|
31
|
+
if file_name =~ /^(jre|jdk|server-jre).*$/
|
|
32
|
+
major_num = file_name.scan(/\d/)[0]
|
|
33
|
+
update_token = file_name.scan(/u(\d+)/)[0]
|
|
34
|
+
update_num = update_token ? update_token[0] : "0"
|
|
35
|
+
# pad a single digit number with a zero
|
|
36
|
+
if update_num.length < 2
|
|
37
|
+
update_num = "0" + update_num
|
|
38
|
+
end
|
|
39
|
+
package_name = (file_name =~ /^server-jre.*$/) ? "jdk" : file_name.scan(/[a-z]+/)[0]
|
|
40
|
+
if update_num == "00"
|
|
41
|
+
app_dir_name = "#{package_name}1.#{major_num}.0"
|
|
42
|
+
else
|
|
43
|
+
app_dir_name = "#{package_name}1.#{major_num}.0_#{update_num}"
|
|
44
|
+
end
|
|
45
|
+
else
|
|
46
|
+
app_dir_name = file_name.split(/(.tgz|.tar.gz|.zip)/)[0]
|
|
47
|
+
app_dir_name = app_dir_name.split("-bin")[0]
|
|
48
|
+
end
|
|
49
|
+
[app_dir_name, file_name]
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def oracle_downloaded?(download_path, new_resource)
|
|
53
|
+
if ::File.exists? download_path
|
|
54
|
+
require 'digest'
|
|
55
|
+
if new_resource.checksum =~ /^[0-9a-f]{32}$/
|
|
56
|
+
downloaded_md5 = Digest::MD5.file(download_path).hexdigest
|
|
57
|
+
downloaded_md5 == new_resource.checksum
|
|
58
|
+
else
|
|
59
|
+
downloaded_sha = Digest::SHA256.file(download_path).hexdigest
|
|
60
|
+
downloaded_sha == new_resource.checksum
|
|
61
|
+
end
|
|
62
|
+
else
|
|
63
|
+
return false
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def download_direct_from_oracle(tarball_name, new_resource)
|
|
68
|
+
download_path = "#{Chef::Config[:file_cache_path]}/#{tarball_name}"
|
|
69
|
+
cookie = "oraclelicense=accept-securebackup-cookie"
|
|
70
|
+
if node['java']['oracle']['accept_oracle_download_terms']
|
|
71
|
+
# install the curl package
|
|
72
|
+
p = package "curl" do
|
|
73
|
+
action :nothing
|
|
74
|
+
end
|
|
75
|
+
# no converge_by block since the package provider will take care of this run_action
|
|
76
|
+
p.run_action(:install)
|
|
77
|
+
description = "download oracle tarball straight from the server"
|
|
78
|
+
converge_by(description) do
|
|
79
|
+
Chef::Log.debug "downloading oracle tarball straight from the source"
|
|
80
|
+
cmd = shell_out!(
|
|
81
|
+
%Q[ curl --create-dirs -L --retry #{new_resource.retries} --retry-delay #{new_resource.retry_delay} --cookie "#{cookie}" #{new_resource.url} -o #{download_path} --connect-timeout #{new_resource.connect_timeout} ]
|
|
82
|
+
)
|
|
83
|
+
end
|
|
84
|
+
else
|
|
85
|
+
Chef::Application.fatal!("You must set the attribute node['java']['oracle']['accept_oracle_download_terms'] to true if you want to download directly from the oracle site!")
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
action :install do
|
|
90
|
+
app_dir_name, tarball_name = parse_app_dir_name(new_resource.url)
|
|
91
|
+
app_root = new_resource.app_home.split('/')[0..-2].join('/')
|
|
92
|
+
app_dir = app_root + '/' + app_dir_name
|
|
93
|
+
if new_resource.group
|
|
94
|
+
app_group = new_resource.group
|
|
95
|
+
else
|
|
96
|
+
app_group = new_resource.owner
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
if !new_resource.default and new_resource.use_alt_suffix
|
|
100
|
+
Chef::Log.debug("processing alternate jdk")
|
|
101
|
+
app_dir = app_dir + "_alt"
|
|
102
|
+
app_home = new_resource.app_home + "_alt"
|
|
103
|
+
else
|
|
104
|
+
app_home = new_resource.app_home
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
unless ::File.exists?(app_dir)
|
|
108
|
+
Chef::Log.info "Adding #{new_resource.name} to #{app_dir}"
|
|
109
|
+
require 'fileutils'
|
|
110
|
+
|
|
111
|
+
unless ::File.exists?(app_root)
|
|
112
|
+
description = "create dir #{app_root} and change owner to #{new_resource.owner}:#{app_group}"
|
|
113
|
+
converge_by(description) do
|
|
114
|
+
FileUtils.mkdir app_root, :mode => new_resource.app_home_mode
|
|
115
|
+
FileUtils.chown new_resource.owner, app_group, app_root
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
if new_resource.url =~ /^http:\/\/download.oracle.com.*$/
|
|
120
|
+
download_path = "#{Chef::Config[:file_cache_path]}/#{tarball_name}"
|
|
121
|
+
if oracle_downloaded?(download_path, new_resource)
|
|
122
|
+
Chef::Log.debug("oracle tarball already downloaded, not downloading again")
|
|
123
|
+
else
|
|
124
|
+
download_direct_from_oracle tarball_name, new_resource
|
|
125
|
+
end
|
|
126
|
+
else
|
|
127
|
+
Chef::Log.debug("downloading tarball from an unofficial repository")
|
|
128
|
+
r = remote_file "#{Chef::Config[:file_cache_path]}/#{tarball_name}" do
|
|
129
|
+
source new_resource.url
|
|
130
|
+
checksum new_resource.checksum
|
|
131
|
+
retries new_resource.retries
|
|
132
|
+
retry_delay new_resource.retry_delay
|
|
133
|
+
mode 0755
|
|
134
|
+
action :nothing
|
|
135
|
+
end
|
|
136
|
+
#no converge by on run_action remote_file takes care of it.
|
|
137
|
+
r.run_action(:create_if_missing)
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
description = "extract compressed data into Chef file cache path and
|
|
141
|
+
move extracted data to #{app_dir}"
|
|
142
|
+
converge_by(description) do
|
|
143
|
+
case tarball_name
|
|
144
|
+
when /^.*\.bin/
|
|
145
|
+
cmd = shell_out(
|
|
146
|
+
%Q[ cd "#{Chef::Config[:file_cache_path]}";
|
|
147
|
+
bash ./#{tarball_name} -noregister
|
|
148
|
+
] )
|
|
149
|
+
unless cmd.exitstatus == 0
|
|
150
|
+
Chef::Application.fatal!("Failed to extract file #{tarball_name}!")
|
|
151
|
+
end
|
|
152
|
+
when /^.*\.zip/
|
|
153
|
+
cmd = shell_out(
|
|
154
|
+
%Q[ unzip "#{Chef::Config[:file_cache_path]}/#{tarball_name}" -d "#{Chef::Config[:file_cache_path]}" ]
|
|
155
|
+
)
|
|
156
|
+
unless cmd.exitstatus == 0
|
|
157
|
+
Chef::Application.fatal!("Failed to extract file #{tarball_name}!")
|
|
158
|
+
end
|
|
159
|
+
when /^.*\.(tar.gz|tgz)/
|
|
160
|
+
cmd = shell_out(
|
|
161
|
+
%Q[ tar xvzf "#{Chef::Config[:file_cache_path]}/#{tarball_name}" -C "#{Chef::Config[:file_cache_path]}" --no-same-owner]
|
|
162
|
+
)
|
|
163
|
+
unless cmd.exitstatus == 0
|
|
164
|
+
Chef::Application.fatal!("Failed to extract file #{tarball_name}!")
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
cmd = shell_out(
|
|
169
|
+
%Q[ mv "#{Chef::Config[:file_cache_path]}/#{app_dir_name}" "#{app_dir}" ]
|
|
170
|
+
)
|
|
171
|
+
unless cmd.exitstatus == 0
|
|
172
|
+
Chef::Application.fatal!(%Q[ Command \' mv "#{Chef::Config[:file_cache_path]}/#{app_dir_name}" "#{app_dir}" \' failed ])
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
# change ownership of extracted files
|
|
176
|
+
FileUtils.chown_R new_resource.owner, app_group, app_root
|
|
177
|
+
end
|
|
178
|
+
new_resource.updated_by_last_action(true)
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
#set up .jinfo file for update-java-alternatives
|
|
182
|
+
java_name = app_home.split('/')[-1]
|
|
183
|
+
jinfo_file = "#{app_root}/.#{java_name}.jinfo"
|
|
184
|
+
if platform_family?("debian") && !::File.exists?(jinfo_file)
|
|
185
|
+
description = "Add #{jinfo_file} for debian"
|
|
186
|
+
converge_by(description) do
|
|
187
|
+
Chef::Log.debug "Adding #{jinfo_file} for debian"
|
|
188
|
+
template jinfo_file do
|
|
189
|
+
cookbook "java"
|
|
190
|
+
source "oracle.jinfo.erb"
|
|
191
|
+
owner new_resource.owner
|
|
192
|
+
group app_group
|
|
193
|
+
variables(
|
|
194
|
+
:priority => new_resource.alternatives_priority,
|
|
195
|
+
:bin_cmds => new_resource.bin_cmds,
|
|
196
|
+
:name => java_name,
|
|
197
|
+
:app_dir => app_home
|
|
198
|
+
)
|
|
199
|
+
action :create
|
|
200
|
+
end
|
|
201
|
+
end
|
|
202
|
+
new_resource.updated_by_last_action(true)
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
#link app_home to app_dir
|
|
206
|
+
Chef::Log.debug "app_home is #{app_home} and app_dir is #{app_dir}"
|
|
207
|
+
current_link = ::File.symlink?(app_home) ? ::File.readlink(app_home) : nil
|
|
208
|
+
if current_link != app_dir
|
|
209
|
+
description = "Symlink #{app_dir} to #{app_home}"
|
|
210
|
+
converge_by(description) do
|
|
211
|
+
Chef::Log.debug "Symlinking #{app_dir} to #{app_home}"
|
|
212
|
+
FileUtils.rm_f app_home
|
|
213
|
+
FileUtils.ln_sf app_dir, app_home
|
|
214
|
+
FileUtils.chown new_resource.owner, app_group, app_home
|
|
215
|
+
end
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
#update-alternatives
|
|
219
|
+
java_alternatives 'set-java-alternatives' do
|
|
220
|
+
java_location app_home
|
|
221
|
+
bin_cmds new_resource.bin_cmds
|
|
222
|
+
priority new_resource.alternatives_priority
|
|
223
|
+
default new_resource.default
|
|
224
|
+
reset_alternatives new_resource.reset_alternatives
|
|
225
|
+
action :set
|
|
226
|
+
end
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
action :remove do
|
|
230
|
+
app_dir_name, tarball_name = parse_app_dir_name(new_resource.url)
|
|
231
|
+
app_root = new_resource.app_home.split('/')[0..-2].join('/')
|
|
232
|
+
app_dir = app_root + '/' + app_dir_name
|
|
233
|
+
|
|
234
|
+
unless new_resource.default
|
|
235
|
+
Chef::Log.debug("processing alternate jdk")
|
|
236
|
+
app_dir = app_dir + "_alt"
|
|
237
|
+
app_home = new_resource.app_home + "_alt"
|
|
238
|
+
else
|
|
239
|
+
app_home = new_resource.app_home
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
if ::File.exists?(app_dir)
|
|
243
|
+
java_alternatives 'unset-java-alternatives' do
|
|
244
|
+
java_location app_home
|
|
245
|
+
bin_cmds new_resource.bin_cmds
|
|
246
|
+
action :unset
|
|
247
|
+
end
|
|
248
|
+
description = "remove #{new_resource.name} at #{app_dir}"
|
|
249
|
+
converge_by(description) do
|
|
250
|
+
Chef::Log.info "Removing #{new_resource.name} at #{app_dir}"
|
|
251
|
+
FileUtils.rm_rf app_dir
|
|
252
|
+
end
|
|
253
|
+
new_resource.updated_by_last_action(true)
|
|
254
|
+
end
|
|
255
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Author:: Seth Chisamore (<schisamo@opscode.com>)
|
|
3
|
+
# Cookbook Name:: java
|
|
4
|
+
# Recipe:: default
|
|
5
|
+
#
|
|
6
|
+
# Copyright 2008-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
|
+
|
|
21
|
+
include_recipe "java::set_attributes_from_version"
|
|
22
|
+
include_recipe "java::#{node['java']['install_flavor']}"
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Cookbook Name:: java
|
|
2
|
+
# Recipe:: default_java_symlink
|
|
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
|
+
link '/usr/lib/jvm/default-java' do
|
|
17
|
+
to node['java']['java_home']
|
|
18
|
+
not_if { node['java']['java_home'] == '/usr/lib/jvm/default-java' }
|
|
19
|
+
end
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Author:: Joshua Timberman (<joshua@opscode.com>)
|
|
2
|
+
# Cookbook Name:: java
|
|
3
|
+
# Recipe:: ibm
|
|
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
|
+
require 'uri'
|
|
20
|
+
|
|
21
|
+
source_url = node['java']['ibm']['url']
|
|
22
|
+
jdk_uri = ::URI.parse(source_url)
|
|
23
|
+
jdk_filename = ::File.basename(jdk_uri.path)
|
|
24
|
+
|
|
25
|
+
unless valid_ibm_jdk_uri?(source_url)
|
|
26
|
+
raise "You must set the attribute `node['java']['ibm']['url']` to a valid HTTP URI"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# "installable package" installer needs rpm on Ubuntu
|
|
30
|
+
if platform_family?('debian') && jdk_filename !~ /archive/
|
|
31
|
+
package "rpm" do
|
|
32
|
+
action :install
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
template "#{Chef::Config[:file_cache_path]}/installer.properties" do
|
|
37
|
+
source "ibm_jdk.installer.properties.erb"
|
|
38
|
+
only_if { node['java']['ibm']['accept_ibm_download_terms'] }
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
remote_file "#{Chef::Config[:file_cache_path]}/#{jdk_filename}" do
|
|
42
|
+
source source_url
|
|
43
|
+
mode 00755
|
|
44
|
+
if node['java']['ibm']['checksum']
|
|
45
|
+
checksum node['java']['ibm']['checksum']
|
|
46
|
+
action :create
|
|
47
|
+
else
|
|
48
|
+
action :create_if_missing
|
|
49
|
+
end
|
|
50
|
+
notifies :run, "execute[install-ibm-java]", :immediately
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
java_alternatives 'set-java-alternatives' do
|
|
54
|
+
java_location node['java']['java_home']
|
|
55
|
+
default node['java']['set_default']
|
|
56
|
+
case node['java']['jdk_version'].to_s
|
|
57
|
+
when "6"
|
|
58
|
+
bin_cmds node['java']['ibm']['6']['bin_cmds']
|
|
59
|
+
when "7"
|
|
60
|
+
bin_cmds node['java']['ibm']['7']['bin_cmds']
|
|
61
|
+
end
|
|
62
|
+
action :nothing
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
execute "install-ibm-java" do
|
|
66
|
+
cwd Chef::Config[:file_cache_path]
|
|
67
|
+
environment({
|
|
68
|
+
"_JAVA_OPTIONS" => "-Dlax.debug.level=3 -Dlax.debug.all=true",
|
|
69
|
+
"LAX_DEBUG" => "1"
|
|
70
|
+
})
|
|
71
|
+
command "./#{jdk_filename} -f ./installer.properties -i silent"
|
|
72
|
+
notifies :set, 'java_alternatives[set-java-alternatives]', :immediately
|
|
73
|
+
creates "#{node['java']['java_home']}/jre/bin/java"
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
include_recipe "java::set_java_home"
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Cookbook Name:: java
|
|
2
|
+
# Recipe:: ibm_tar
|
|
3
|
+
#
|
|
4
|
+
# Copyright 2013, Opscode, Inc.
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
|
|
18
|
+
require 'uri'
|
|
19
|
+
|
|
20
|
+
source_url = node['java']['ibm']['url']
|
|
21
|
+
jdk_uri = ::URI.parse(source_url)
|
|
22
|
+
jdk_filename = ::File.basename(jdk_uri.path)
|
|
23
|
+
|
|
24
|
+
unless valid_ibm_jdk_uri?(source_url)
|
|
25
|
+
raise "You must set the attribute `node['java']['ibm']['url']` to a valid URI"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
unless jdk_filename =~ /\.(tar.gz|tgz)$/
|
|
29
|
+
raise "The attribute `node['java']['ibm']['url']` must specify a .tar.gz file"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
remote_file "#{Chef::Config[:file_cache_path]}/#{jdk_filename}" do
|
|
33
|
+
source source_url
|
|
34
|
+
mode 00755
|
|
35
|
+
if node['java']['ibm']['checksum']
|
|
36
|
+
checksum node['java']['ibm']['checksum']
|
|
37
|
+
action :create
|
|
38
|
+
else
|
|
39
|
+
action :create_if_missing
|
|
40
|
+
end
|
|
41
|
+
notifies :create, "directory[create-java-home]", :immediately
|
|
42
|
+
notifies :run, "execute[untar-ibm-java]", :immediately
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
directory "create-java-home" do
|
|
46
|
+
path node['java']['java_home']
|
|
47
|
+
mode 00755
|
|
48
|
+
recursive true
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
java_alternatives 'set-java-alternatives' do
|
|
52
|
+
java_location node['java']['java_home']
|
|
53
|
+
default node['java']['set_default']
|
|
54
|
+
case node['java']['jdk_version'].to_s
|
|
55
|
+
when "6"
|
|
56
|
+
bin_cmds node['java']['ibm']['6']['bin_cmds']
|
|
57
|
+
when "7"
|
|
58
|
+
bin_cmds node['java']['ibm']['7']['bin_cmds']
|
|
59
|
+
end
|
|
60
|
+
action :nothing
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
execute "untar-ibm-java" do
|
|
64
|
+
cwd Chef::Config[:file_cache_path]
|
|
65
|
+
command "tar xzf ./#{jdk_filename} -C #{node['java']['java_home']} --strip 1"
|
|
66
|
+
notifies :set, 'java_alternatives[set-java-alternatives]', :immediately
|
|
67
|
+
creates "#{node['java']['java_home']}/jre/bin/java"
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
include_recipe "java::set_java_home"
|