Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[COOK-487] support for Sun Java on CentOS/RHEL

  • Loading branch information...
commit 66bb8676ec4281542f5c5f911cce3a43a9ada5f8 1 parent f1aa576
@schisamo schisamo authored
View
36 java/README.md
@@ -1,7 +1,7 @@
Description
===========
-Installs a Java. Uses OpenJDK by default but supports installation of the Sun's Java (Debian and Ubuntu platforms only).
+Installs a Java. Uses OpenJDK by default but supports installation of the Sun's Java.
---
Requirements
@@ -10,8 +10,8 @@ Requirements
Platform
--------
-* Debian, Ubuntu (OpenJDK, Sun)
-* CentOS, Red Hat, Fedora (OpenJDK)
+* Debian, Ubuntu
+* CentOS, Red Hat, Fedora
Cookbooks
---------
@@ -41,19 +41,41 @@ This recipe installs the `openjdk` flavor of Java.
sun
---
-This recipe installs the `sun` flavor of Java. The Sun flavor of Java is only supported on Debian and Ubuntu systems, the recipe will preseed the package and update java alternatives.
+This recipe installs the `sun` flavor of Java.
+
+On Debian and Ubuntu systems the recipe will add the correct apt repository (`non-free` on Debian or `partner` on Ubuntu), pre-seed the package and update java alternatives.
+
+On Red Hat flavored Linux (RHEL, CentOS, Fedora), the installation of the Sun flavor of Java is slightly more complicated as the `rpm` package is not readily available in any public Yum repository. The Sun JDK `rpm` package can be downloaded directly from Sun but comes wrapped as a compressed bin file. After the file has been downloaded, decompressed and license accepted the `rpm` package (names something like `jdk-6u25-ea-linux-amd64.rpm`) can be retrieved by this recipe using the `remote_file` or `cookbook_file` resources. The recipe will choose the correct resource based on the existence (or non-existence) of the `node['sun']['rpm_url']` attribute. See below for an example role using this attribute in the proper way. If you would like to deliver the `rpm` package file as part of this cookbook place the `rpm` package file in the `files/default` directory and the cookbook will retrieve the file during installation.
---
Usage
=====
-Simply include the `php` recipe where ever you would like php installed. To install from source override the `node['java']['install_flavor']` attribute with in a role:
+Simply include the `java` recipe where ever you would like Java installed.
+
+To install Sun flavored Java on Debian or Ubuntu override the `node['java']['install_flavor']` attribute with in role:
+
+ name "java"
+ description "Install Sun Java on Ubuntu"
+ override_attributes(
+ "java" => {
+ "install_flavor" => "sun"
+ }
+ )
+ run_list(
+ "recipe[java]"
+ )
+
+On RedHat flavored Linux be sure to set the `rpm_url` and `rpm_checksum` attributes if you placed the `rpm` file on a remote server:
name "java"
- description "Install Sun Java."
+ description "Install Sun Java on CentOS"
override_attributes(
"java" => {
- "install_flavor" => "source"
+ "install_flavor" => "sun",
+ "version" => "6u25",
+ "rpm_url" => "https://mycompany.s3.amazonaws.com/sun_jdk",
+ "rpm_checksum" => "c473e3026f991e617710bad98f926435959303fe084a5a31140ad5ad75d7bf13"
}
)
run_list(
View
11 java/attributes/default.rb
@@ -1,4 +1,5 @@
#
+# Author:: Seth Chisamore (<schisamo@opscode.com>)
# Cookbook Name:: java
# Attributes:: default
#
@@ -16,11 +17,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-default["java"]["install_flavor"] = "openjdk"
+default['java']['install_flavor'] = "openjdk"
case platform
when "centos","redhat","fedora"
- set["java"]["java_home"] = "/usr/lib/jvm/java"
+ default['java']['version'] = "6u25"
+ default['java']['arch'] = kernel['machine'] =~ /x86_64/ ? "amd64" : "i586"
+ set['java']['java_home'] = "/usr/lib/jvm/java"
else
- set["java"]["java_home"] = "/usr/lib/jvm/default-java"
-end
+ set['java']['java_home'] = "/usr/lib/jvm/default-java"
+end
View
2  java/metadata.json
@@ -1,7 +1,7 @@
{
"name": "java",
"description": "Installs Java runtime.",
- "long_description": "Description\n===========\n\nInstalls a Java. Uses OpenJDK by default but supports installation of the Sun's Java (Debian and Ubuntu platforms only).\n\n---\nRequirements\n============\n\nPlatform\n--------\n\n* Debian, Ubuntu (OpenJDK, Sun)\n* CentOS, Red Hat, Fedora (OpenJDK)\n\nCookbooks\n---------\n\n* apt\n\n---\nAttributes\n==========\n\n* `node[\"java\"][\"install_flavor\"]` - Flavor of JVM you would like installed (`sun` or `openjdk`), default `openjdk`.\n\n---\nRecipes\n=======\n\ndefault\n-------\n\nInclude the default recipe in a run list, to get `java`. By default the `openjdk` flavor of Java is installed, but this can be changed by using the `install_flavor` attribute.\n\nopenjdk\n-------\n\nThis recipe installs the `openjdk` flavor of Java.\n\nsun\n---\n\nThis recipe installs the `sun` flavor of Java. The Sun flavor of Java is only supported on Debian and Ubuntu systems, the recipe will preseed the package and update java alternatives.\n\n---\nUsage\n=====\n\nSimply include the `php` recipe where ever you would like php installed. To install from source override the `node['java']['install_flavor']` attribute with in a role:\n\n name \"java\"\n description \"Install Sun Java.\"\n override_attributes(\n \"java\" => {\n \"install_flavor\" => \"source\"\n }\n )\n run_list(\n \"recipe[java]\"\n )\n\nLicense and Author\n==================\n\nAuthor:: Seth Chisamore (<schisamo@opscode.com>)\n\nCopyright:: 2008-2011, Opscode, Inc\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",
+ "long_description": "Description\n===========\n\nInstalls a Java. Uses OpenJDK by default but supports installation of the Sun's Java (Debian and Ubuntu platforms only).\n\n---\nRequirements\n============\n\nPlatform\n--------\n\n* Debian, Ubuntu (OpenJDK, Sun)\n* CentOS, Red Hat, Fedora (OpenJDK, Sun)\n\nCookbooks\n---------\n\n* apt\n\n---\nAttributes\n==========\n\n* `node[\"java\"][\"install_flavor\"]` - Flavor of JVM you would like installed (`sun` or `openjdk`), default `openjdk`.\n\n---\nRecipes\n=======\n\ndefault\n-------\n\nInclude the default recipe in a run list, to get `java`. By default the `openjdk` flavor of Java is installed, but this can be changed by using the `install_flavor` attribute.\n\nopenjdk\n-------\n\nThis recipe installs the `openjdk` flavor of Java.\n\nsun\n---\n\nThis recipe installs the `sun` flavor of Java. \n\nOn Debian and Ubuntu systems the recipe will add the correct apt repository (Debian non-free or Ubuntu partner), preseed the package and update java alternatives.\n\nOn RedHat flavored Linux (RHEL, CentOS, Fedora), the installation of the Sun flavor of Java is slightly more complicated as the `rpm` package is not readily available in any public Yum repository. The `rpm` package can be downloaded directly from Sun but comes wrapped as a compressed bin file. After the file has been downloaded, decompressed and license accepted the `rpm` package can be retrieved by this recipe using the `remote_file` or `cookbook_file` resources. The recipe will choose the correct resource based on the existence of the `node['sun']['rpm_url']` attribute. See below for an example role using this attribute in the proper way. If you would like to deliver the `rpm` package file as part of this cookbook place the `rpm` package file in the `files/default` directory and the cookbook will retrieve the file during installation.\n\n---\nUsage\n=====\n\nSimply include the `java` recipe where ever you would like Java installed. \n\nTo install Sun flavored Java on Debian or Ubuntu override the `node['java']['install_flavor']` attribute with in role:\n\n name \"java\"\n description \"Install Sun Java on Ubuntu\"\n override_attributes(\n \"java\" => {\n \"install_flavor\" => \"sun\"\n }\n )\n run_list(\n \"recipe[java]\"\n )\n\nOn RedHat flavored Linux be sure to set the `rpm_url` attribute if you placed the `rpm` file on a remote server:\n\n name \"java\"\n description \"Install Sun Java on CentOS\"\n override_attributes(\n \"java\" => {\n \"install_flavor\" => \"sun\",\n \"version\" => \"6u24\",\n \"rpm_url\" => \"https://s3.amazonaws.com/foo\"\n }\n )\n run_list(\n \"recipe[java]\"\n )\n\n\n\nLicense and Author\n==================\n\nAuthor:: Seth Chisamore (<schisamo@opscode.com>)\n\nCopyright:: 2008-2011, Opscode, Inc\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",
"maintainer": "Opscode, Inc.",
"maintainer_email": "cookbooks@opscode.com",
"license": "Apache 2.0",
View
2  java/metadata.rb
@@ -3,7 +3,7 @@
license "Apache 2.0"
description "Installs Java runtime."
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
-version "1.0"
+version "1.1"
depends "apt"
View
4 java/recipes/openjdk.rb
@@ -21,14 +21,14 @@
["centos","redhat","fedora"] => {
"default" => ["java-1.6.0-openjdk","java-1.6.0-openjdk-devel"]
},
- "default" => ["openjdk-6-jre","openjdk-6-jdk","default-jre"]
+ "default" => ["openjdk-6-jdk","default-jdk"]
)
execute "update-java-alternatives" do
command "update-java-alternatives -s java-6-openjdk"
returns [0,2]
action :nothing
- only_if do platform?("ubuntu", "debian") end
+ only_if { platform?("ubuntu", "debian") }
end
pkgs.each do |pkg|
View
36 java/recipes/sun.rb
@@ -19,15 +19,16 @@
pkgs = value_for_platform(
["centos","redhat","fedora"] => {
- "default" => [""]
+ "default" => ["jdk-#{node['java']['version']}-ea-linux-#{node['java']['arch']}.rpm"]
},
["debian","ubuntu"] => {
- "default" => ["sun-java6-jre","sun-java6-jdk"]
+ "default" => ["sun-java6-jdk"]
}
)
case node['platform']
when "ubuntu"
+
apt_repository "ubuntu-partner" do
uri "http://archive.canonical.com/ubuntu"
distribution node['lsb']['codename']
@@ -36,7 +37,9 @@
end
# update-java-alternatives doesn't work with only sun java installed
node.set['java']['java_home'] = "/usr/lib/jvm/java-6-sun"
+
when "debian"
+
apt_repository "debian-non-free" do
uri "http://http.us.debian.org/debian"
distribution "stable"
@@ -45,6 +48,25 @@
end
# update-java-alternatives doesn't work with only sun java installed
node.set['java']['java_home'] = "/usr/lib/jvm/java-6-sun"
+
+when "centos", "redhat", "fedora"
+
+ pkgs.each do |pkg|
+ if node['java'].attribute?('rpm_url')
+ remote_file "#{Chef::Config[:file_cache_path]}/#{pkg}" do
+ source "#{node['java']['rpm_url']}/#{pkg}"
+ checksum node['java']['rpm_checksum']
+ mode "0644"
+ end
+ else
+ cookbook_file "#{Chef::Config[:file_cache_path]}/#{pkg}" do
+ source pkg
+ mode "0644"
+ action :create_if_missing
+ end
+ end
+ end
+
else
Chef::Log.error("Installation of Sun Java packages not supported on this platform.")
end
@@ -53,12 +75,18 @@
command "update-java-alternatives -s java-6-sun"
returns [0,2]
action :nothing
- only_if do platform?("ubuntu", "debian") end
+ only_if { platform?("ubuntu", "debian") }
end
pkgs.each do |pkg|
package pkg do
- response_file "java.seed" if platform?("ubuntu", "debian")
+ case node['platform']
+ when "ubuntu", "debian"
+ response_file "java.seed"
+ when "centos", "redhat", "fedora"
+ source "#{Chef::Config[:file_cache_path]}/#{pkg}"
+ options "--nogpgcheck" # sun/oracle doesn't sign their RPMs o_O
+ end
action :install
notifies :run, "execute[update-java-alternatives]"
end
Please sign in to comment.
Something went wrong with that request. Please try again.