Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Import java version 1.1.0

  • Loading branch information...
commit 5bf5abafb7fd0b359ce4b563310b2661bae506f6 1 parent b5b0f43
@schisamo schisamo authored
View
102 cookbooks/java/README.md
@@ -0,0 +1,102 @@
+Description
+===========
+
+Installs a Java. Uses OpenJDK by default but supports installation of the Sun's Java.
+
+---
+Requirements
+============
+
+Platform
+--------
+
+* Debian, Ubuntu
+* CentOS, Red Hat, Fedora
+
+Cookbooks
+---------
+
+* apt
+
+---
+Attributes
+==========
+
+* `node["java"]["install_flavor"]` - Flavor of JVM you would like installed (`sun` or `openjdk`), default `openjdk`.
+
+---
+Recipes
+=======
+
+default
+-------
+
+Include 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.
+
+openjdk
+-------
+
+This recipe installs the `openjdk` flavor of Java.
+
+sun
+---
+
+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 `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 on CentOS"
+ override_attributes(
+ "java" => {
+ "install_flavor" => "sun",
+ "version" => "6u25",
+ "rpm_url" => "https://mycompany.s3.amazonaws.com/sun_jdk",
+ "rpm_checksum" => "c473e3026f991e617710bad98f926435959303fe084a5a31140ad5ad75d7bf13"
+ }
+ )
+ run_list(
+ "recipe[java]"
+ )
+
+License and Author
+==================
+
+Author:: Seth Chisamore (<schisamo@opscode.com>)
+
+Copyright:: 2008-2011, Opscode, 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.
View
29 cookbooks/java/attributes/default.rb
@@ -0,0 +1,29 @@
+#
+# Author:: Seth Chisamore (<schisamo@opscode.com>)
+# Cookbook Name:: java
+# Attributes:: default
+#
+# Copyright 2010, Opscode, 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.
+
+default['java']['install_flavor'] = "openjdk"
+
+case platform
+when "centos","redhat","fedora"
+ 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
View
11 cookbooks/java/files/default/java.seed
@@ -0,0 +1,11 @@
+sun-java6-bin shared/accepted-sun-dlj-v1-1 boolean true
+sun-java6-jdk shared/accepted-sun-dlj-v1-1 boolean true
+sun-java6-jre shared/accepted-sun-dlj-v1-1 boolean true
+sun-java6-jre sun-java6-jre/stopthread boolean true
+sun-java6-jre sun-java6-jre/jcepolicy note
+sun-java6-bin shared/error-sun-dlj-v1-1 error
+sun-java6-jdk shared/error-sun-dlj-v1-1 error
+sun-java6-jre shared/error-sun-dlj-v1-1 error
+sun-java6-bin shared/present-sun-dlj-v1-1 note
+sun-java6-jdk shared/present-sun-dlj-v1-1 note
+sun-java6-jre shared/present-sun-dlj-v1-1 note
View
50 cookbooks/java/metadata.json
@@ -0,0 +1,50 @@
+{
+ "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.\n\n---\nRequirements\n============\n\nPlatform\n--------\n\n* Debian, Ubuntu\n* CentOS, Red Hat, Fedora\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 (`non-free` on Debian or `partner` on Ubuntu), pre-seed the package and update java alternatives.\n\nOn 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.\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` and `rpm_checksum` attributes 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\" => \"6u25\",\n \"rpm_url\" => \"https://mycompany.s3.amazonaws.com/sun_jdk\",\n \"rpm_checksum\" => \"c473e3026f991e617710bad98f926435959303fe084a5a31140ad5ad75d7bf13\"\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",
+ "maintainer": "Opscode, Inc.",
+ "maintainer_email": "cookbooks@opscode.com",
+ "license": "Apache 2.0",
+ "platforms": {
+ "debian": [
+
+ ],
+ "ubuntu": [
+
+ ],
+ "centos": [
+
+ ],
+ "redhat": [
+
+ ],
+ "fedora": [
+
+ ]
+ },
+ "dependencies": {
+ "apt": [
+
+ ]
+ },
+ "recommendations": {
+ },
+ "suggestions": {
+ },
+ "conflicting": {
+ },
+ "providing": {
+ },
+ "replacing": {
+ },
+ "attributes": {
+ },
+ "groupings": {
+ },
+ "recipes": {
+ "java": "Installs Java runtime",
+ "java::openjdk": "Installs the OpenJDK flavor of Java",
+ "java::sun": "Installs the Sun flavor of Java"
+ },
+ "version": "1.1.0"
+}
View
16 cookbooks/java/metadata.rb
@@ -0,0 +1,16 @@
+maintainer "Opscode, Inc."
+maintainer_email "cookbooks@opscode.com"
+license "Apache 2.0"
+description "Installs Java runtime."
+long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
+version "1.1"
+
+depends "apt"
+
+recipe "java", "Installs Java runtime"
+recipe "java::openjdk", "Installs the OpenJDK flavor of Java"
+recipe "java::sun", "Installs the Sun flavor of Java"
+
+%w{ debian ubuntu centos redhat fedora }.each do |os|
+ supports os
+end
View
21 cookbooks/java/recipes/default.rb
@@ -0,0 +1,21 @@
+#
+# Author:: Seth Chisamore (<schisamo@opscode.com>)
+# Cookbook Name:: java
+# Recipe:: default
+#
+# Copyright 2008-2011, Opscode, 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::#{node['java']['install_flavor']}"
View
39 cookbooks/java/recipes/openjdk.rb
@@ -0,0 +1,39 @@
+#
+# Author:: Seth Chisamore (<schisamo@opscode.com>)
+# Cookbook Name:: java
+# Recipe:: openjdk
+#
+# Copyright 2010-2011, Opscode, 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.
+
+pkgs = value_for_platform(
+ ["centos","redhat","fedora"] => {
+ "default" => ["java-1.6.0-openjdk","java-1.6.0-openjdk-devel"]
+ },
+ "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 { platform?("ubuntu", "debian") }
+end
+
+pkgs.each do |pkg|
+ package pkg do
+ action :install
+ notifies :run, "execute[update-java-alternatives]"
+ end
+end
View
93 cookbooks/java/recipes/sun.rb
@@ -0,0 +1,93 @@
+#
+# Author:: Seth Chisamore (<schisamo@opscode.com>)
+# Cookbook Name:: java
+# Recipe:: sun
+#
+# Copyright 2010-2011, Opscode, 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.
+
+pkgs = value_for_platform(
+ ["centos","redhat","fedora"] => {
+ "default" => ["jdk-#{node['java']['version']}-ea-linux-#{node['java']['arch']}.rpm"]
+ },
+ ["debian","ubuntu"] => {
+ "default" => ["sun-java6-jdk"]
+ }
+)
+
+case node['platform']
+when "ubuntu"
+
+ apt_repository "ubuntu-partner" do
+ uri "http://archive.canonical.com/ubuntu"
+ distribution node['lsb']['codename']
+ components ['partner']
+ action :add
+ 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"
+ components ['main','contrib','non-free']
+ action :add
+ 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
+
+execute "update-java-alternatives" do
+ command "update-java-alternatives -s java-6-sun"
+ returns [0,2]
+ action :nothing
+ only_if { platform?("ubuntu", "debian") }
+end
+
+pkgs.each do |pkg|
+ package pkg do
+ 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
+end
Please sign in to comment.
Something went wrong with that request. Please try again.