Vendor the external cookbooks
Knife-Zero doesn't include Berkshelf support, so vendoring everything in the repo is convenient again
This commit is contained in:
46
cookbooks/java/recipes/adoptopenjdk.rb
Normal file
46
cookbooks/java/recipes/adoptopenjdk.rb
Normal file
@@ -0,0 +1,46 @@
|
||||
# Cookbook:: java
|
||||
# Recipe:: adoptopenjdk
|
||||
|
||||
include_recipe 'java::notify'
|
||||
|
||||
unless node.recipe?('java::default')
|
||||
Chef::Log.warn('Using java::default instead is recommended.')
|
||||
|
||||
# Even if this recipe is included by itself, a safety check is nice...
|
||||
if node['java']['java_home'].nil? || node['java']['java_home'].empty?
|
||||
include_recipe 'java::set_attributes_from_version'
|
||||
end
|
||||
end
|
||||
|
||||
include_recipe 'java::set_java_home'
|
||||
|
||||
java_home = node['java']['java_home']
|
||||
arch = node['java']['arch']
|
||||
version = node['java']['jdk_version'].to_s
|
||||
variant = node['java']['adoptopenjdk']['variant']
|
||||
tarball_url = node['java']['adoptopenjdk'][version][arch][variant]['url']
|
||||
tarball_checksum = node['java']['adoptopenjdk'][version][arch][variant]['checksum']
|
||||
bin_cmds = if node['java']['adoptopenjdk'][version]['bin_cmds'].key?(variant)
|
||||
node['java']['adoptopenjdk'][version]['bin_cmds'][variant]
|
||||
else
|
||||
node['java']['adoptopenjdk'][version]['bin_cmds']['default']
|
||||
end
|
||||
|
||||
adoptopenjdk_install 'adoptopenjdk' do
|
||||
url tarball_url
|
||||
default node['java']['set_default']
|
||||
checksum tarball_checksum
|
||||
app_home java_home
|
||||
bin_cmds bin_cmds
|
||||
alternatives_priority node['java']['alternatives_priority']
|
||||
retries node['java']['ark_retries']
|
||||
retry_delay node['java']['ark_retry_delay']
|
||||
reset_alternatives node['java']['reset_alternatives']
|
||||
variant variant
|
||||
action :install
|
||||
notifies :write, 'log[jdk-version-changed]', :immediately
|
||||
end
|
||||
|
||||
if node['java']['set_default'] && platform_family?('debian')
|
||||
include_recipe 'java::default_java_symlink'
|
||||
end
|
||||
46
cookbooks/java/recipes/corretto.rb
Normal file
46
cookbooks/java/recipes/corretto.rb
Normal file
@@ -0,0 +1,46 @@
|
||||
# Cookbook:: java
|
||||
# Recipe:: corretto
|
||||
# This recipe installs and configures Amazon's Corretto package
|
||||
# https://aws.amazon.com/corretto/
|
||||
|
||||
include_recipe 'java::notify'
|
||||
|
||||
unless node.recipe?('java::default')
|
||||
Chef::Log.warn('Using java::default instead is recommended.')
|
||||
|
||||
# Even if this recipe is included by itself, a safety check is nice...
|
||||
if node['java']['java_home'].nil? || node['java']['java_home'].empty?
|
||||
include_recipe 'java::set_attributes_from_version'
|
||||
end
|
||||
end
|
||||
|
||||
java_home = node['java']['java_home']
|
||||
arch = node['java']['arch']
|
||||
version = node['java']['jdk_version'].to_s
|
||||
tarball_url = node['java']['corretto'][version][arch]['url']
|
||||
tarball_checksum = node['java']['corretto'][version][arch]['checksum']
|
||||
bin_cmds = node['java']['corretto'][version]['bin_cmds']
|
||||
|
||||
include_recipe 'java::set_java_home'
|
||||
|
||||
java_oracle_install 'jdk' do
|
||||
url tarball_url
|
||||
default node['java']['set_default']
|
||||
md5 tarball_checksum
|
||||
app_home java_home
|
||||
bin_cmds bin_cmds
|
||||
alternatives_priority node['java']['alternatives_priority']
|
||||
retries node['java']['ark_retries']
|
||||
retry_delay node['java']['ark_retry_delay']
|
||||
connect_timeout node['java']['ark_timeout']
|
||||
use_alt_suffix node['java']['use_alt_suffix']
|
||||
reset_alternatives node['java']['reset_alternatives']
|
||||
download_timeout node['java']['ark_download_timeout']
|
||||
proxy node['java']['ark_proxy']
|
||||
action :install
|
||||
notifies :write, 'log[jdk-version-changed]', :immediately
|
||||
end
|
||||
|
||||
if node['java']['set_default'] && platform_family?('debian')
|
||||
include_recipe 'java::default_java_symlink'
|
||||
end
|
||||
22
cookbooks/java/recipes/default.rb
Normal file
22
cookbooks/java/recipes/default.rb
Normal file
@@ -0,0 +1,22 @@
|
||||
#
|
||||
# Author:: Seth Chisamore (<schisamo@chef.io>)
|
||||
# Cookbook:: java
|
||||
# Recipe:: default
|
||||
#
|
||||
# Copyright:: 2008-2015, Chef Software, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
include_recipe 'java::set_attributes_from_version'
|
||||
include_recipe "java::#{node['java']['install_flavor']}"
|
||||
19
cookbooks/java/recipes/default_java_symlink.rb
Normal file
19
cookbooks/java/recipes/default_java_symlink.rb
Normal file
@@ -0,0 +1,19 @@
|
||||
# Cookbook:: java
|
||||
# Recipe:: default_java_symlink
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
link '/usr/lib/jvm/default-java' do
|
||||
to node['java']['java_home']
|
||||
not_if { node['java']['java_home'] == '/usr/lib/jvm/default-java' }
|
||||
end
|
||||
8
cookbooks/java/recipes/homebrew.rb
Normal file
8
cookbooks/java/recipes/homebrew.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
include_recipe 'homebrew'
|
||||
include_recipe 'homebrew::cask'
|
||||
include_recipe 'java::notify'
|
||||
|
||||
homebrew_tap 'caskroom/versions'
|
||||
homebrew_cask "java#{node['java']['jdk_version']}" do
|
||||
notifies :write, 'log[jdk-version-changed]', :immediately
|
||||
end
|
||||
83
cookbooks/java/recipes/ibm.rb
Normal file
83
cookbooks/java/recipes/ibm.rb
Normal file
@@ -0,0 +1,83 @@
|
||||
# Author:: Joshua Timberman (<joshua@chef.io>)
|
||||
# Cookbook:: java
|
||||
# Recipe:: ibm
|
||||
#
|
||||
# Copyright:: 2013-2015, Chef Software, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
require 'uri'
|
||||
|
||||
include_recipe 'java::notify'
|
||||
|
||||
# If you need to override this in an attribute file you must use
|
||||
# force_default or higher precedence.
|
||||
node.default['java']['java_home'] = '/opt/ibm/java'
|
||||
|
||||
source_url = node['java']['ibm']['url']
|
||||
jdk_uri = ::URI.parse(source_url)
|
||||
jdk_filename = ::File.basename(jdk_uri.path)
|
||||
|
||||
unless valid_ibm_jdk_uri?(source_url)
|
||||
raise "You must set the attribute `node['java']['ibm']['url']` to a valid HTTP URI"
|
||||
end
|
||||
|
||||
# "installable package" installer needs rpm on Ubuntu
|
||||
package 'rpm' do
|
||||
action :install
|
||||
only_if { platform_family?('debian') && jdk_filename !~ /archive/ }
|
||||
end
|
||||
|
||||
template "#{node['java']['download_path']}/installer.properties" do
|
||||
source 'ibm_jdk.installer.properties.erb'
|
||||
only_if { node['java']['ibm']['accept_ibm_download_terms'] }
|
||||
end
|
||||
|
||||
remote_file "#{node['java']['download_path']}/#{jdk_filename}" do
|
||||
source source_url
|
||||
mode '0755'
|
||||
if node['java']['ibm']['checksum']
|
||||
checksum node['java']['ibm']['checksum']
|
||||
action :create
|
||||
else
|
||||
action :create_if_missing
|
||||
end
|
||||
notifies :run, 'execute[install-ibm-java]', :immediately
|
||||
end
|
||||
|
||||
java_alternatives 'set-java-alternatives' do
|
||||
java_location node['java']['java_home']
|
||||
default node['java']['set_default']
|
||||
case node['java']['jdk_version'].to_s
|
||||
when '6'
|
||||
bin_cmds node['java']['ibm']['6']['bin_cmds']
|
||||
when '7'
|
||||
bin_cmds node['java']['ibm']['7']['bin_cmds']
|
||||
when '8'
|
||||
bin_cmds node['java']['ibm']['8']['bin_cmds']
|
||||
end
|
||||
action :nothing
|
||||
end
|
||||
|
||||
execute 'install-ibm-java' do
|
||||
cwd node['java']['download_path']
|
||||
environment('_JAVA_OPTIONS' => '-Dlax.debug.level=3 -Dlax.debug.all=true',
|
||||
'LAX_DEBUG' => '1')
|
||||
command "./#{jdk_filename} -f ./installer.properties -i silent"
|
||||
creates "#{node['java']['java_home']}/jre/bin/java"
|
||||
|
||||
notifies :set, 'java_alternatives[set-java-alternatives]', :immediately
|
||||
notifies :write, 'log[jdk-version-changed]', :immediately
|
||||
end
|
||||
|
||||
include_recipe 'java::set_java_home'
|
||||
79
cookbooks/java/recipes/ibm_tar.rb
Normal file
79
cookbooks/java/recipes/ibm_tar.rb
Normal file
@@ -0,0 +1,79 @@
|
||||
# Cookbook:: java
|
||||
# Recipe:: ibm_tar
|
||||
#
|
||||
# Copyright:: 2013-2015, Chef Software, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
require 'uri'
|
||||
|
||||
include_recipe 'java::notify'
|
||||
|
||||
# If you need to override this in an attribute file you must use
|
||||
# force_default or higher precedence.
|
||||
node.default['java']['java_home'] = '/opt/ibm/java'
|
||||
|
||||
source_url = node['java']['ibm']['url']
|
||||
jdk_uri = ::URI.parse(source_url)
|
||||
jdk_filename = ::File.basename(jdk_uri.path)
|
||||
|
||||
unless valid_ibm_jdk_uri?(source_url)
|
||||
raise "You must set the attribute `node['java']['ibm']['url']` to a valid URI"
|
||||
end
|
||||
|
||||
unless jdk_filename =~ /\.(tar.gz|tgz)$/
|
||||
raise "The attribute `node['java']['ibm']['url']` must specify a .tar.gz file"
|
||||
end
|
||||
|
||||
remote_file "#{node['java']['download_path']}/#{jdk_filename}" do
|
||||
source source_url
|
||||
mode '0755'
|
||||
if node['java']['ibm']['checksum']
|
||||
checksum node['java']['ibm']['checksum']
|
||||
action :create
|
||||
else
|
||||
action :create_if_missing
|
||||
end
|
||||
notifies :create, 'directory[create-java-home]', :immediately
|
||||
notifies :run, 'execute[untar-ibm-java]', :immediately
|
||||
end
|
||||
|
||||
directory 'create-java-home' do
|
||||
path node['java']['java_home']
|
||||
mode '0755'
|
||||
recursive true
|
||||
end
|
||||
|
||||
java_alternatives 'set-java-alternatives' do
|
||||
java_location node['java']['java_home']
|
||||
default node['java']['set_default']
|
||||
case node['java']['jdk_version'].to_s
|
||||
when '6'
|
||||
bin_cmds node['java']['ibm']['6']['bin_cmds']
|
||||
when '7'
|
||||
bin_cmds node['java']['ibm']['7']['bin_cmds']
|
||||
when '8'
|
||||
bin_cmds node['java']['ibm']['8']['bin_cmds']
|
||||
end
|
||||
action :nothing
|
||||
end
|
||||
|
||||
execute 'untar-ibm-java' do
|
||||
cwd node['java']['download_path']
|
||||
command "tar xzf ./#{jdk_filename} -C #{node['java']['java_home']} --strip 1"
|
||||
notifies :set, 'java_alternatives[set-java-alternatives]', :immediately
|
||||
notifies :write, 'log[jdk-version-changed]', :immediately
|
||||
creates "#{node['java']['java_home']}/jre/bin/java"
|
||||
end
|
||||
|
||||
include_recipe 'java::set_java_home'
|
||||
33
cookbooks/java/recipes/notify.rb
Normal file
33
cookbooks/java/recipes/notify.rb
Normal file
@@ -0,0 +1,33 @@
|
||||
#
|
||||
# Author:: Eric Helgeson (<eric@agileorbit.com>)
|
||||
# Cookbook:: java
|
||||
# Recipe:: notify
|
||||
#
|
||||
# Copyright:: 2008-2015, Chef Software, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
# This resource is avalible for other recipes to subscribe to so they can be
|
||||
# notified of a JDK change. For example you want to restart a service to take
|
||||
# advantage of the new JDK
|
||||
# eg:
|
||||
# service 'somejavaservice'
|
||||
# action :restart
|
||||
# subscribes :write, 'log[jdk-version-changed]', :delayed
|
||||
# end
|
||||
log 'jdk-version-changed' do
|
||||
message 'A new version of java was installed'
|
||||
level :info
|
||||
action :nothing
|
||||
end
|
||||
72
cookbooks/java/recipes/openjdk.rb
Normal file
72
cookbooks/java/recipes/openjdk.rb
Normal file
@@ -0,0 +1,72 @@
|
||||
# Author:: Bryan W. Berry (<bryan.berry@gmail.com>)
|
||||
# Author:: Seth Chisamore (<schisamo@chef.io>)
|
||||
# Author:: Joshua Timberman (<joshua@chef.io>)
|
||||
#
|
||||
# Cookbook:: java
|
||||
# Recipe:: openjdk
|
||||
#
|
||||
# Copyright:: 2010-2015, Chef Software, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
include_recipe 'java::notify'
|
||||
|
||||
unless node.recipe?('java::default')
|
||||
Chef::Log.warn('Using java::default instead is recommended.')
|
||||
|
||||
# Even if this recipe is included by itself, a safety check is nice...
|
||||
[node['java']['openjdk_packages'], node['java']['java_home']].each do |v|
|
||||
include_recipe 'java::set_attributes_from_version' if v.nil? || v.empty?
|
||||
end
|
||||
end
|
||||
|
||||
jdk = ChefCookbook::OpenJDK.new(node)
|
||||
|
||||
if platform_requires_license_acceptance?
|
||||
file '/opt/local/.dlj_license_accepted' do
|
||||
owner 'root'
|
||||
group 'root'
|
||||
mode '0400'
|
||||
action :create
|
||||
only_if { node['java']['accept_license_agreement'] }
|
||||
end
|
||||
end
|
||||
|
||||
if node['platform'] == 'ubuntu'
|
||||
apt_repository 'openjdk-r-ppa' do
|
||||
uri 'ppa:openjdk-r'
|
||||
distribution node['lsb']['codename']
|
||||
end
|
||||
end
|
||||
|
||||
package node['java']['openjdk_packages'] do
|
||||
version node['java']['openjdk_version'] if node['java']['openjdk_version']
|
||||
notifies :write, 'log[jdk-version-changed]', :immediately
|
||||
end
|
||||
|
||||
java_alternatives 'set-java-alternatives' do
|
||||
java_location jdk.java_home
|
||||
default node['java']['set_default']
|
||||
priority 1100
|
||||
bin_cmds node['java']['jdk'][node['java']['jdk_version'].to_s]['bin_cmds']
|
||||
action :set
|
||||
only_if { platform_family?('debian', 'rhel', 'fedora', 'amazon') }
|
||||
end
|
||||
|
||||
if node['java']['set_default'] && platform_family?('debian')
|
||||
include_recipe 'java::default_java_symlink'
|
||||
end
|
||||
|
||||
# We must include this recipe AFTER updating the alternatives or else JAVA_HOME
|
||||
# will not point to the correct java.
|
||||
include_recipe 'java::set_java_home'
|
||||
62
cookbooks/java/recipes/oracle.rb
Normal file
62
cookbooks/java/recipes/oracle.rb
Normal file
@@ -0,0 +1,62 @@
|
||||
#
|
||||
# Author:: Bryan W. Berry (<bryan.berry@gmail.com>)
|
||||
# Cookbook:: java
|
||||
# Recipe:: oracle
|
||||
#
|
||||
# Copyright:: 2011, Bryan w. Berry
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
include_recipe 'java::notify'
|
||||
|
||||
unless node.recipe?('java::default')
|
||||
Chef::Log.warn('Using java::default instead is recommended.')
|
||||
|
||||
# Even if this recipe is included by itself, a safety check is nice...
|
||||
if node['java']['java_home'].nil? || node['java']['java_home'].empty?
|
||||
include_recipe 'java::set_attributes_from_version'
|
||||
end
|
||||
end
|
||||
|
||||
java_home = node['java']['java_home']
|
||||
arch = node['java']['arch']
|
||||
version = node['java']['jdk_version'].to_s
|
||||
tarball_url = node['java']['jdk'][version][arch]['url']
|
||||
tarball_checksum = node['java']['jdk'][version][arch]['checksum']
|
||||
bin_cmds = node['java']['jdk'][version]['bin_cmds']
|
||||
|
||||
include_recipe 'java::set_java_home'
|
||||
|
||||
java_oracle_install 'jdk' do
|
||||
url tarball_url
|
||||
default node['java']['set_default']
|
||||
checksum tarball_checksum
|
||||
app_home java_home
|
||||
bin_cmds bin_cmds
|
||||
alternatives_priority node['java']['alternatives_priority']
|
||||
retries node['java']['ark_retries']
|
||||
retry_delay node['java']['ark_retry_delay']
|
||||
connect_timeout node['java']['ark_timeout']
|
||||
use_alt_suffix node['java']['use_alt_suffix']
|
||||
reset_alternatives node['java']['reset_alternatives']
|
||||
download_timeout node['java']['ark_download_timeout']
|
||||
proxy node['java']['ark_proxy']
|
||||
action :install
|
||||
notifies :write, 'log[jdk-version-changed]', :immediately
|
||||
end
|
||||
|
||||
if node['java']['set_default'] && platform_family?('debian')
|
||||
include_recipe 'java::default_java_symlink'
|
||||
end
|
||||
|
||||
include_recipe 'java::oracle_jce' if node['java']['oracle']['jce']['enabled']
|
||||
74
cookbooks/java/recipes/oracle_i386.rb
Normal file
74
cookbooks/java/recipes/oracle_i386.rb
Normal file
@@ -0,0 +1,74 @@
|
||||
#
|
||||
# Author:: Bryan W. Berry (<bryan.berry@gmail.com>)
|
||||
# Cookbook:: java
|
||||
# Recipe:: oracle_i386
|
||||
#
|
||||
# Copyright:: 2010-2015, Chef Software, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
include_recipe 'java::notify'
|
||||
|
||||
unless node.recipe?('java::default')
|
||||
Chef::Log.warn('Using java::default instead is recommended.')
|
||||
|
||||
# Even if this recipe is included by itself, a safety check is nice...
|
||||
if node['java']['java_home'].nil? || node['java']['java_home'].empty?
|
||||
include_recipe 'java::set_attributes_from_version'
|
||||
end
|
||||
end
|
||||
|
||||
java_home = node['java']['java_home']
|
||||
|
||||
case node['java']['jdk_version'].to_s
|
||||
when '6'
|
||||
tarball_url = node['java']['jdk']['6']['i586']['url']
|
||||
tarball_checksum = node['java']['jdk']['6']['i586']['checksum']
|
||||
bin_cmds = node['java']['jdk']['6']['bin_cmds']
|
||||
when '7'
|
||||
tarball_url = node['java']['jdk']['7']['i586']['url']
|
||||
tarball_checksum = node['java']['jdk']['7']['i586']['checksum']
|
||||
bin_cmds = node['java']['jdk']['7']['bin_cmds']
|
||||
when '8'
|
||||
tarball_url = node['java']['jdk']['8']['i586']['url']
|
||||
tarball_checksum = node['java']['jdk']['8']['i586']['checksum']
|
||||
bin_cmds = node['java']['jdk']['8']['bin_cmds']
|
||||
end
|
||||
|
||||
include_recipe 'java::set_java_home'
|
||||
|
||||
yum_package 'glibc' do
|
||||
arch 'i686'
|
||||
only_if { platform_family?('rhel', 'fedora', 'amazon') }
|
||||
end
|
||||
|
||||
java_oracle_install 'jdk-alt' do
|
||||
url tarball_url
|
||||
default node['java']['set_default']
|
||||
checksum tarball_checksum
|
||||
app_home java_home
|
||||
bin_cmds bin_cmds
|
||||
retries node['java']['ark_retries']
|
||||
retry_delay node['java']['ark_retries']
|
||||
use_alt_suffix node['java']['use_alt_suffix']
|
||||
reset_alternatives node['java']['reset_alternatives']
|
||||
action :install
|
||||
default false
|
||||
notifies :write, 'log[jdk-version-changed]', :immediately
|
||||
end
|
||||
|
||||
if node['java']['set_default'] && platform_family?('debian')
|
||||
include_recipe 'java::default_java_symlink'
|
||||
end
|
||||
|
||||
include_recipe 'java::oracle_jce' if node['java']['oracle']['jce']['enabled']
|
||||
21
cookbooks/java/recipes/oracle_jce.rb
Normal file
21
cookbooks/java/recipes/oracle_jce.rb
Normal file
@@ -0,0 +1,21 @@
|
||||
#
|
||||
# Author:: Kyle McGovern (<spion06@gmail.com>)
|
||||
# Cookbook:: java
|
||||
# Recipe:: oracle_jce
|
||||
#
|
||||
# Copyright:: 2014, Kyle McGovern
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
jdk_version = node['java']['jdk_version'].to_s
|
||||
java_jce "Install JCE for JDK #{jdk_version}"
|
||||
61
cookbooks/java/recipes/oracle_rpm.rb
Normal file
61
cookbooks/java/recipes/oracle_rpm.rb
Normal file
@@ -0,0 +1,61 @@
|
||||
# Author:: Christophe Arguel (<christophe.arguel@free.fr>)
|
||||
#
|
||||
# Cookbook:: java
|
||||
# Recipe:: oracle_rpm
|
||||
#
|
||||
# Copyright:: 2013, Christophe Arguel <christophe.arguel@free.fr>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# If you need to override this in an attribute file you must use
|
||||
# force_default or higher precedence.
|
||||
node.default['java']['java_home'] = '/usr/java/latest'
|
||||
|
||||
include_recipe 'java::set_java_home'
|
||||
include_recipe 'java::notify'
|
||||
|
||||
slave_cmds = case node['java']['oracle_rpm']['type']
|
||||
when 'jdk'
|
||||
%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)
|
||||
|
||||
when 'jre'
|
||||
%w(ControlPanel java_vm javaws jcontrol keytool orbd pack200 policytool rmid rmiregistry servertool tnameserv unpack200)
|
||||
|
||||
else
|
||||
Chef::Application.fatal!("Unsupported oracle RPM type (#{node['java']['oracle_rpm']['type']})")
|
||||
end
|
||||
|
||||
bash 'update-java-alternatives' do
|
||||
java_home = node['java']['java_home']
|
||||
java_location = File.join(java_home, 'bin', 'java')
|
||||
slave_lines = slave_cmds.inject('') do |slaves, cmd|
|
||||
slaves << "--slave /usr/bin/#{cmd} #{cmd} #{File.join(java_home, 'bin', cmd)} \\\n"
|
||||
end
|
||||
|
||||
code <<-EOH.gsub(/^\s+/, '')
|
||||
update-alternatives --install /usr/bin/java java #{java_location} #{node['java']['alternatives_priority']} \
|
||||
#{slave_lines} && \
|
||||
update-alternatives --set java #{java_location}
|
||||
EOH
|
||||
action :nothing
|
||||
end
|
||||
|
||||
package_name = node['java']['oracle_rpm']['package_name'] || node['java']['oracle_rpm']['type']
|
||||
package package_name do
|
||||
action :install
|
||||
version node['java']['oracle_rpm']['package_version'] if node['java']['oracle_rpm']['package_version']
|
||||
notifies :run, 'bash[update-java-alternatives]', :immediately if platform_family?('rhel', 'fedora', 'amazon') && node['java']['set_default']
|
||||
notifies :write, 'log[jdk-version-changed]', :immediately
|
||||
end
|
||||
|
||||
include_recipe 'java::oracle_jce' if node['java']['oracle']['jce']['enabled']
|
||||
76
cookbooks/java/recipes/set_attributes_from_version.rb
Normal file
76
cookbooks/java/recipes/set_attributes_from_version.rb
Normal file
@@ -0,0 +1,76 @@
|
||||
# Cookbook:: java
|
||||
# Recipe:: set_attributes_from_version
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# Calculate variables that depend on jdk_version
|
||||
# If you need to override this in an attribute file you must use
|
||||
# force_default or higher precedence.
|
||||
|
||||
case node['platform_family']
|
||||
when 'rhel', 'fedora', 'amazon'
|
||||
node.default['java']['java_home'] = case node['java']['install_flavor']
|
||||
when 'adoptopenjdk'
|
||||
"/usr/lib/jvm/java-#{node['java']['jdk_version'].to_i}-#{node['java']['install_flavor']}-#{node['java']['adoptopenjdk']['variant']}"
|
||||
when 'oracle'
|
||||
'/usr/lib/jvm/java'
|
||||
when 'oracle_rpm'
|
||||
'/usr/java/latest'
|
||||
else
|
||||
node['java']['jdk_version'].to_i < 11 ? "/usr/lib/jvm/java-1.#{node['java']['jdk_version']}.0" : "/usr/lib/jvm/java-#{node['java']['jdk_version']}"
|
||||
end
|
||||
node.default['java']['openjdk_packages'] = node['java']['jdk_version'].to_i < 11 ? ["java-1.#{node['java']['jdk_version']}.0-openjdk", "java-1.#{node['java']['jdk_version']}.0-openjdk-devel"] : ["java-#{node['java']['jdk_version']}-openjdk", "java-#{node['java']['jdk_version']}-openjdk-devel"]
|
||||
when 'suse'
|
||||
node.default['java']['java_home'] = case node['java']['install_flavor']
|
||||
when 'adoptopenjdk'
|
||||
"/usr/lib/jvm/java-#{node['java']['jdk_version'].to_i}-#{node['java']['install_flavor']}-#{node['java']['adoptopenjdk']['variant']}"
|
||||
when 'oracle'
|
||||
'/usr/lib/jvm/java'
|
||||
when 'oracle_rpm'
|
||||
'/usr/java/latest'
|
||||
else
|
||||
"/usr/lib#{node['kernel']['machine'] == 'x86_64' ? '64' : nil}/jvm/java-1.#{node['java']['jdk_version']}.0"
|
||||
end
|
||||
node.default['java']['openjdk_packages'] = ["java-1_#{node['java']['jdk_version']}_0-openjdk", "java-1_#{node['java']['jdk_version']}_0-openjdk-devel"]
|
||||
when 'freebsd'
|
||||
node.default['java']['java_home'] = "/usr/local/openjdk#{node['java']['jdk_version']}"
|
||||
jdk_version = node['java']['jdk_version']
|
||||
openjdk_package = jdk_version == '7' ? 'openjdk' : "openjdk#{node['java']['jdk_version']}"
|
||||
node.default['java']['openjdk_packages'] = [openjdk_package]
|
||||
when 'arch'
|
||||
node.default['java']['java_home'] = "/usr/lib/jvm/java-#{node['java']['jdk_version']}-openjdk"
|
||||
node.default['java']['openjdk_packages'] = ["openjdk#{node['java']['jdk_version']}"]
|
||||
when 'debian'
|
||||
node.default['java']['java_home'] = case node['java']['install_flavor']
|
||||
when 'adoptopenjdk'
|
||||
"/usr/lib/jvm/java-#{node['java']['jdk_version'].to_i}-#{node['java']['install_flavor']}-#{node['java']['adoptopenjdk']['variant']}"
|
||||
else
|
||||
"/usr/lib/jvm/java-#{node['java']['jdk_version']}-#{node['java']['install_flavor']}-#{node['kernel']['machine'] == 'x86_64' ? 'amd64' : 'i386'}"
|
||||
end
|
||||
node.default['java']['openjdk_packages'] = ["openjdk-#{node['java']['jdk_version']}-jdk", "openjdk-#{node['java']['jdk_version']}-jre-headless"]
|
||||
when 'smartos'
|
||||
node.default['java']['java_home'] = '/opt/local/java/sun6'
|
||||
node.default['java']['openjdk_packages'] = ["sun-jdk#{node['java']['jdk_version']}", "sun-jre#{node['java']['jdk_version']}"]
|
||||
when 'windows'
|
||||
node.default['java']['java_home'] = nil
|
||||
when 'mac_os_x'
|
||||
java_home = if node['java']['jdk_version'].to_i >= 10
|
||||
"$(/usr/libexec/java_home -v #{node['java']['jdk_version']})"
|
||||
else
|
||||
"$(/usr/libexec/java_home -v 1.#{node['java']['jdk_version']})"
|
||||
end
|
||||
node.default['java']['java_home'] = java_home
|
||||
else
|
||||
node.default['java']['java_home'] = '/usr/lib/jvm/default-java'
|
||||
node.default['java']['openjdk_packages'] = ["openjdk-#{node['java']['jdk_version']}-jdk"]
|
||||
end
|
||||
37
cookbooks/java/recipes/set_java_home.rb
Normal file
37
cookbooks/java/recipes/set_java_home.rb
Normal file
@@ -0,0 +1,37 @@
|
||||
# Author:: Joshua Timberman (<joshua@chef.io>)
|
||||
# Cookbook:: java
|
||||
# Recipe:: set_java_home
|
||||
#
|
||||
# Copyright:: 2013-2015, Chef Software, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
directory '/etc/profile.d' do
|
||||
mode '0755'
|
||||
end
|
||||
|
||||
template '/etc/profile.d/jdk.sh' do
|
||||
source 'jdk.sh.erb'
|
||||
mode '0755'
|
||||
end
|
||||
|
||||
if node['java']['set_etc_environment']
|
||||
ruby_block 'Set JAVA_HOME in /etc/environment' do
|
||||
block do
|
||||
file = Chef::Util::FileEdit.new('/etc/environment')
|
||||
file.insert_line_if_no_match(/^JAVA_HOME=/, "JAVA_HOME=#{node['java']['java_home']}")
|
||||
file.search_file_replace_line(/^JAVA_HOME=/, "JAVA_HOME=#{node['java']['java_home']}")
|
||||
file.write_file
|
||||
end
|
||||
end
|
||||
end
|
||||
109
cookbooks/java/recipes/windows.rb
Normal file
109
cookbooks/java/recipes/windows.rb
Normal file
@@ -0,0 +1,109 @@
|
||||
#
|
||||
# Author:: Kendrick Martin (<kendrick.martin@webtrends.com>)
|
||||
# Cookbook:: java
|
||||
# Recipe:: windows
|
||||
#
|
||||
# Copyright:: 2008-2012 Webtrends, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require 'uri'
|
||||
|
||||
include_recipe 'java::notify'
|
||||
|
||||
Chef::Log.fatal('No download url set for java installer.') unless node['java'] && node['java']['windows'] && node['java']['windows']['url']
|
||||
|
||||
pkg_checksum = node['java']['windows']['checksum']
|
||||
aws_access_key_id = node['java']['windows']['aws_access_key_id']
|
||||
aws_secret_access_key = node['java']['windows']['aws_secret_access_key']
|
||||
aws_session_token = node['java']['windows']['aws_session_token']
|
||||
|
||||
s3_bucket = node['java']['windows']['bucket']
|
||||
s3_remote_path = node['java']['windows']['remote_path']
|
||||
|
||||
uri = ::URI.parse(node['java']['windows']['url'])
|
||||
cache_file_path = File.join(node['java']['download_path'], File.basename(::URI.unescape(uri.path)))
|
||||
|
||||
if s3_bucket && s3_remote_path
|
||||
aws_s3_file cache_file_path do
|
||||
aws_access_key_id aws_access_key_id
|
||||
aws_secret_access_key aws_secret_access_key
|
||||
aws_session_token aws_session_token
|
||||
checksum pkg_checksum if pkg_checksum
|
||||
bucket s3_bucket
|
||||
remote_path s3_remote_path
|
||||
backup false
|
||||
action :create
|
||||
end
|
||||
else
|
||||
ruby_block 'Enable Accessing cookies' do
|
||||
block do
|
||||
cookie_jar = Chef::HTTP::CookieJar
|
||||
|
||||
cookie_jar.instance["#{uri.host}:#{uri.port}"] = 'oraclelicense=accept-securebackup-cookie'
|
||||
end
|
||||
|
||||
only_if { node['java']['oracle']['accept_oracle_download_terms'] }
|
||||
end
|
||||
|
||||
remote_file cache_file_path do
|
||||
checksum pkg_checksum if pkg_checksum
|
||||
source node['java']['windows']['url']
|
||||
backup false
|
||||
action :create
|
||||
end
|
||||
end
|
||||
|
||||
if node['java'].attribute?('java_home') && !node['java']['java_home'].nil?
|
||||
java_home_win = win_friendly_path(node['java']['java_home'])
|
||||
additional_options = if node['java']['jdk_version'].to_s == '8'
|
||||
# Seems that the jdk 8 EXE installer does not need anymore the /v /qn flags
|
||||
"INSTALLDIR=\"#{java_home_win}\""
|
||||
else
|
||||
# The jdk 7 EXE installer expects escaped quotes, so we need to double escape
|
||||
# them here. The final string looks like :
|
||||
# /v"/qn INSTALLDIR=\"C:\Program Files\Java\""
|
||||
"/v\"/qn INSTALLDIR=\\\"#{java_home_win}\\\"\""
|
||||
end
|
||||
|
||||
env 'JAVA_HOME' do
|
||||
value java_home_win
|
||||
end
|
||||
|
||||
# update path
|
||||
windows_path "#{java_home_win}\\bin" do
|
||||
action :add
|
||||
end
|
||||
end
|
||||
|
||||
if node['java']['windows'].attribute?('public_jre_home') && node['java']['windows']['public_jre_home']
|
||||
java_publicjre_home_win = win_friendly_path(node['java']['windows']['public_jre_home'])
|
||||
additional_options = "#{additional_options} /INSTALLDIRPUBJRE=\"#{java_publicjre_home_win}\""
|
||||
end
|
||||
|
||||
if node['java']['windows'].attribute?('remove_obsolete') && node['java']['windows']['remove_obsolete']
|
||||
additional_options = "#{additional_options} REMOVEOUTOFDATEJRES=1"
|
||||
end
|
||||
|
||||
windows_package node['java']['windows']['package_name'] do
|
||||
source cache_file_path
|
||||
checksum node['java']['windows']['checksum']
|
||||
action :install
|
||||
returns node['java']['windows']['returns']
|
||||
installer_type :custom
|
||||
options "/s #{additional_options}"
|
||||
notifies :write, 'log[jdk-version-changed]', :immediately
|
||||
end
|
||||
|
||||
include_recipe 'java::oracle_jce' if node['java']['oracle']['jce']['enabled']
|
||||
Reference in New Issue
Block a user