├── README.md ├── attributes └── default.rb ├── metadata.rb ├── providers └── ark.rb ├── recipes ├── default.rb ├── openjdk.rb ├── oracle.rb └── oracle_i386.rb └── resources └── ark.rb /README.md: -------------------------------------------------------------------------------- 1 | Description 2 | =========== 3 | 4 | Installs a Java. Uses OpenJDK by default but supports installation of Oracle's JDK. 5 | 6 | This cookbook also provides the `java_ark` LWRP which other java 7 | cookbooks can use to install java-related applications from binary 8 | packages. 9 | 10 | The `java_ark` LWPR may move to its own cookbook at some point in the 11 | future as its functionality is useful for other purposes. 12 | 13 | Requirements 14 | ============ 15 | 16 | Platform 17 | -------- 18 | 19 | * Debian, Ubuntu 20 | * CentOS, Red Hat, Fedora, Scientific, Amazon 21 | * ArchLinux 22 | * FreeBSD 23 | 24 | Attributes 25 | ========== 26 | 27 | See `attributes/default.rb` for default values. 28 | 29 | * `node["java"]["install_flavor"]` - Flavor of JVM you would like installed (`oracle` or `openjdk`), default `openjdk`. 30 | * `node['java']['java_home']` - Default location of the "`$JAVA_HOME`". 31 | * `node['java']['tarball']` - name of the tarball to retrieve from your corporate repository default `jdk1.6.0_29_i386.tar.gz` 32 | * `node['java']['tarball_checksum']` - checksum for the tarball, if you use a different tarball, you also need to create a new sha256 checksum 33 | * `node['java']['jdk']` - version and architecture specific attributes 34 | for setting the URL on Oracle's site for the JDK, and the checksum 35 | of the .tar.gz. 36 | 37 | Recipes 38 | ======= 39 | 40 | default 41 | ------- 42 | 43 | Include the default recipe in a run list, to get `java`. By default 44 | the `openjdk` flavor of Java is installed, but this can be changed by 45 | using the `install_flavor` attribute. 46 | 47 | OpenJDK is the default because of licensing changes made upstream by 48 | Oracle. See notes on the `oracle` recipe below. 49 | 50 | openjdk 51 | ------- 52 | 53 | This recipe installs the `openjdk` flavor of Java. 54 | 55 | oracle 56 | ------ 57 | 58 | This recipe installs the `oracle` flavor of Java. This recipe does not 59 | use distribution packages as Oracle changed the licensing terms with 60 | JDK 1.6u27 and prohibited the practice for both the debian and EL worlds. 61 | 62 | For both debian and centos/rhel, this recipe pulls the binary 63 | distribution from the Oracle website, and installs it in the default 64 | JAVA_HOME for each distribution. For debian/ubuntu, this is 65 | /usr/lib/jvm/default-java. For Centos/RHEL, this is /usr/lib/jvm/java 66 | 67 | After putting the binaries in place, the oracle recipe updates 68 | /usr/bin/java to point to the installed JDK using the 69 | `update-alternatives` script 70 | 71 | oracle_i386 72 | ----------- 73 | 74 | This recipe installs the 32-bit Java virtual machine without setting 75 | it as the default. This can be useful if you have applications on the 76 | same machine that require different versions of the JVM. 77 | 78 | Resources/Providers 79 | =================== 80 | 81 | This LWRP provides an easy way to manage java applications. It uses 82 | the LWRP arkive (deliberately misspelled). It is an arkive and not an 83 | "archive" because the `java_ark` lwrp is not the same as a java 84 | archive or "jar". Essentially, you provide the `java_ark` with the URL 85 | to a tarball and the commands within the extracted result that you 86 | want symlinked to /usr/bin/ 87 | 88 | The `java_ark` LWPR may move to its own cookbook at some point in the 89 | future as its functionality is useful for other purposes. 90 | 91 | By default, the extracted directory is extracted to 92 | `app_root/extracted_dir_name` and symlinked to `app_root/default` 93 | 94 | # Actions 95 | 96 | - `:install`: extracts the tarball and makes necessary symlinks 97 | - `:remove`: removes the tarball and run update-alternatives for all 98 | symlinked `bin_cmds` 99 | 100 | # Attribute Parameters 101 | 102 | - `url`: path to tarball, .tar.gz, .bin (oracle-specific), and .zip 103 | currently supported 104 | - `checksum`: sha256 checksum, not used for security but avoid 105 | redownloading the archive on each chef-client run 106 | - `app_home`: the default for installations of this type of 107 | application, for example, `/usr/lib/tomcat/default`. If your 108 | application is not set to the default, it will be placed at the same 109 | level in the directory hierarchy but the directory name will be 110 | `app_root/extracted_directory_name + "_alt"` 111 | - `app_home_mode`: file mode for app_home, is an integer 112 | - `bin_cmds`: array of binary commands that should be symlinked to 113 | /usr/bin, examples are mvn, java, javac, etc. These cmds must be in 114 | the bin/ subdirectory of the extracted folder. Will be ignored if this 115 | java_ark is not the default 116 | - `owner`: owner of extracted directory, set to "root" by default 117 | - `default`: whether this the default installation of this package, 118 | boolean true or false 119 | 120 | 121 | # Examples 122 | 123 | # install jdk6 from Oracle 124 | java_ark "jdk" do 125 | url 'http://download.oracle.com/otn-pub/java/jdk/6u29-b11/jdk-6u29-linux-x64.bin' 126 | checksum 'a8603fa62045ce2164b26f7c04859cd548ffe0e33bfc979d9fa73df42e3b3365' 127 | app_home '/usr/local/java/default' 128 | bin_cmds ["java", "javac"] 129 | action :install 130 | end 131 | 132 | # installs maven2 133 | java_ark "maven2" do 134 | url "http://www.apache.org/dist/maven/binaries/apache-maven-2.2.1-bin.tar.gz" 135 | checksum "b9a36559486a862abfc7fb2064fd1429f20333caae95ac51215d06d72c02d376" 136 | app_home "/usr/local/maven/default" 137 | bin_cmds ["mvn"] 138 | action :install 139 | end 140 | 141 | Usage 142 | ===== 143 | 144 | Simply include the `java` recipe where ever you would like Java installed. 145 | 146 | To install Oracle flavored Java on Debian or Ubuntu override the `node['java']['install_flavor']` attribute with in role: 147 | 148 | name "java" 149 | description "Install Oracle Java on Ubuntu" 150 | override_attributes( 151 | "java" => { 152 | "install_flavor" => "oracle" 153 | } 154 | ) 155 | run_list( 156 | "recipe[java]" 157 | ) 158 | 159 | Changes 160 | ======= 161 | 162 | ## v1.4.0: 163 | 164 | * [COOK-858] - numerous updates: handle jdk6 and 7, switch from sun to 165 | oracle, make openjdk default, add `java_ark` LWRP. 166 | * [COOK-942] - FreeBSD support 167 | * [COOK-520] - ArchLinux support 168 | 169 | License and Author 170 | ================== 171 | 172 | Author:: Seth Chisamore () 173 | Author:: Bryan W. Berry () 174 | 175 | Copyright:: 2008-2012, Opscode, Inc 176 | 177 | Licensed under the Apache License, Version 2.0 (the "License"); 178 | you may not use this file except in compliance with the License. 179 | You may obtain a copy of the License at 180 | 181 | http://www.apache.org/licenses/LICENSE-2.0 182 | 183 | Unless required by applicable law or agreed to in writing, software 184 | distributed under the License is distributed on an "AS IS" BASIS, 185 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 186 | See the License for the specific language governing permissions and 187 | limitations under the License. 188 | -------------------------------------------------------------------------------- /attributes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Seth Chisamore () 3 | # Cookbook Name:: java 4 | # Attributes:: ark 5 | # 6 | # Copyright 2010, Opscode, Inc. 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | 20 | # default jdk attributes 21 | default['java']['install_flavor'] = "openjdk" 22 | default['java']['jdk_version'] = '6' 23 | default['java']['arch'] = kernel['machine'] =~ /x86_64/ ? "x86_64" : "i586" 24 | 25 | case platform 26 | when "centos","redhat","fedora" 27 | default['java']['java_home'] = "/usr/lib/jvm/java" 28 | when "freebsd" 29 | default['java']['java_home'] = "/usr/local/openjdk#{java['jdk_version']}" 30 | when "arch" 31 | default['java']['java_home'] = "//usr/lib/jvm/java-#{java['jdk_version']}-openjdk" 32 | else 33 | default['java']['java_home'] = "/usr/lib/jvm/default-java" 34 | end 35 | 36 | # jdk6 attributes 37 | # x86_64 38 | default['java']['jdk']['6']['x86_64']['url'] = 'http://download.oracle.com/otn-pub/java/jdk/6u30-b12/jdk-6u30-linux-x64.bin' 39 | default['java']['jdk']['6']['x86_64']['checksum'] = '928220f4e46c5dabef0440791c48023945629d8a23998e072157e04960d8a759' 40 | 41 | # i586 42 | default['java']['jdk']['6']['i586']['url'] = 'http://download.oracle.com/otn-pub/java/jdk/6u30-b12/jdk-6u30-linux-i586.bin' 43 | default['java']['jdk']['6']['i586']['checksum'] = 'b551be83a690bc9fec0107d9aa4f828cd47e150fa54cbedbfa8f80c99e2f18b5' 44 | 45 | # jdk7 attributes 46 | # x86_64 47 | default['java']['jdk']['7']['x86_64']['url'] = 'http://download.oracle.com/otn-pub/java/jdk/7u2-b13/jdk-7u2-linux-x64.tar.gz' 48 | default['java']['jdk']['7']['x86_64']['checksum'] = '411a204122c5e45876d6edae1a031b718c01e6175833740b406e8aafc37bc82d' 49 | 50 | # i586 51 | default['java']['jdk']['7']['i586']['url'] = 'http://download.oracle.com/otn-pub/java/jdk/7u2-b13/jdk-7u2-linux-i586.tar.gz' 52 | default['java']['jdk']['7']['i586']['checksum'] = '74faad48fef2c368276dbd1fd6c02520b0e9ebdcb1621916c1af345fc3ba65d1' 53 | -------------------------------------------------------------------------------- /metadata.rb: -------------------------------------------------------------------------------- 1 | maintainer "Opscode, Inc." 2 | maintainer_email "cookbooks@opscode.com" 3 | license "Apache 2.0" 4 | description "Installs Java runtime." 5 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) 6 | version "1.4.0" 7 | 8 | recipe "java", "Installs Java runtime" 9 | recipe "java::openjdk", "Installs the OpenJDK flavor of Java" 10 | recipe "java::oracle", "Installs the Oracle flavor of Java" 11 | recipe "java::oracle_i386", "Installs the 32-bit jvm without setting it as the default" 12 | 13 | 14 | %w{ debian ubuntu centos redhat scientific fedora amazon arch freebsd }.each do |os| 15 | supports os 16 | end 17 | -------------------------------------------------------------------------------- /providers/ark.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Bryan W. Berry () 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 | def parse_app_dir_name url 21 | file_name = url.split('/')[-1] 22 | # funky logic to parse oracle's non-standard naming convention 23 | # for jdk1.6 24 | if file_name =~ /^(jre|jdk).*$/ 25 | major_num = file_name.scan(/\d/)[0] 26 | update_num = file_name.scan(/\d+/)[1] 27 | # pad a single digit number with a zero 28 | if update_num.length < 2 29 | update_num = "0" + update_num 30 | end 31 | package_name = file_name.scan(/[a-z]+/)[0] 32 | app_dir_name = "#{package_name}1.#{major_num}.0_#{update_num}" 33 | else 34 | app_dir_name = file_name.split(/(.tar.gz|.zip)/)[0] 35 | app_dir_name = app_dir_name.split("-bin")[0] 36 | end 37 | [app_dir_name, file_name] 38 | end 39 | 40 | action :install do 41 | app_dir_name, tarball_name = parse_app_dir_name(new_resource.url) 42 | app_root = new_resource.app_home.split('/')[0..-2].join('/') 43 | app_dir = app_root + '/' + app_dir_name 44 | 45 | unless new_resource.default 46 | Chef::Log.debug("processing alternate jdk") 47 | app_dir = app_dir + "_alt" 48 | app_home = app_dir 49 | else 50 | app_home = new_resource.app_home 51 | end 52 | 53 | unless ::File.exists?(app_dir) 54 | Chef::Log.info "Adding #{new_resource.name} to #{app_dir}" 55 | require 'fileutils' 56 | 57 | unless ::File.exists?(app_root) 58 | FileUtils.mkdir app_root, :mode => new_resource.app_home_mode 59 | FileUtils.chown new_resource.owner, new_resource.owner, app_root 60 | end 61 | 62 | r = remote_file "#{Chef::Config[:file_cache_path]}/#{tarball_name}" do 63 | source new_resource.url 64 | checksum new_resource.checksum 65 | mode 0755 66 | action :nothing 67 | end 68 | r.run_action(:create_if_missing) 69 | 70 | require 'tmpdir' 71 | 72 | tmpdir = Dir.mktmpdir 73 | case tarball_name 74 | when /^.*\.bin/ 75 | cmd = Chef::ShellOut.new( 76 | %Q[ cd "#{tmpdir}"; 77 | cp "#{Chef::Config[:file_cache_path]}/#{tarball_name}" . ; 78 | bash ./#{tarball_name} -noregister 79 | ] ).run_command 80 | unless cmd.exitstatus == 0 81 | Chef::Application.fatal!("Failed to extract file #{tarball_name}!") 82 | end 83 | when /^.*\.zip/ 84 | cmd = Chef::ShellOut.new( 85 | %Q[ unzip "#{Chef::Config[:file_cache_path]}/#{tarball_name}" -d "#{tmpdir}" ] 86 | ).run_command 87 | unless cmd.exitstatus == 0 88 | Chef::Application.fatal!("Failed to extract file #{tarball_name}!") 89 | end 90 | when /^.*\.tar.gz/ 91 | cmd = Chef::ShellOut.new( 92 | %Q[ tar xvzf "#{Chef::Config[:file_cache_path]}/#{tarball_name}" -C "#{tmpdir}" ] 93 | ).run_command 94 | unless cmd.exitstatus == 0 95 | Chef::Application.fatal!("Failed to extract file #{tarball_name}!") 96 | end 97 | end 98 | 99 | cmd = Chef::ShellOut.new( 100 | %Q[ mv "#{tmpdir}/#{app_dir_name}" "#{app_dir}" ] 101 | ).run_command 102 | unless cmd.exitstatus == 0 103 | Chef::Application.fatal!(%Q[ Command \' mv "#{tmpdir}/#{app_dir_name}" "#{app_dir}" \' failed ]) 104 | end 105 | FileUtils.rm_r tmpdir 106 | new_resource.updated_by_last_action(true) 107 | end 108 | 109 | #update-alternatives 110 | if new_resource.default 111 | Chef::Log.debug "app_home is #{app_home} and app_dir is #{app_dir}" 112 | current_link = ::File.symlink?(app_home) ? ::File.readlink(app_home) : nil 113 | if current_link != app_dir 114 | Chef::Log.debug "symlinking #{app_dir} to #{app_home}" 115 | FileUtils.rm_f app_home 116 | FileUtils.ln_sf app_dir, app_home 117 | end 118 | if new_resource.bin_cmds 119 | new_resource.bin_cmds.each do |cmd| 120 | if ::File.exists? "/usr/bin/#{cmd}" 121 | current_bin_link = ::File.readlink("/usr/bin/#{cmd}") 122 | else 123 | current_bin_link = false 124 | end 125 | should_be_link = "#{app_home}/bin/#{cmd}" 126 | if current_bin_link != should_be_link 127 | cmd = Chef::ShellOut.new( 128 | %Q[ update-alternatives --install /usr/bin/#{cmd} #{cmd} #{app_home}/bin/#{cmd} 1; 129 | update-alternatives --set #{cmd} #{app_home}/bin/#{cmd} ] 130 | ).run_command 131 | unless cmd.exitstatus == 0 132 | Chef::Application.fatal!(%Q[ update alternatives failed ]) 133 | end 134 | end 135 | end 136 | end 137 | end 138 | end 139 | 140 | action :remove do 141 | app_dir_name, tarball_name = parse_app_dir_name(new_resource.url) 142 | app_root = new_resource.app_home.split('/')[0..-2].join('/') 143 | app_dir = app_root + '/' + app_dir_name 144 | 145 | if ::File.exists?(app_dir) 146 | new_resource.bin_cmds.each do |cmd| 147 | cmd = execute "update_alternatives" do 148 | command "update-alternatives --remove #{cmd} #{app_dir} " 149 | returns [0,2] 150 | action :nothing 151 | end 152 | cmd.run_action(:run) 153 | end 154 | Chef::Log.info "Removing #{new_resource.name} at #{app_dir}" 155 | FileUtils.rm_rf app_dir 156 | new_resource.updated_by_last_action(true) 157 | end 158 | end 159 | -------------------------------------------------------------------------------- /recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Seth Chisamore () 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::#{node['java']['install_flavor']}" 22 | -------------------------------------------------------------------------------- /recipes/openjdk.rb: -------------------------------------------------------------------------------- 1 | # Author:: Bryan W. Berry () 2 | # Author:: Seth Chisamore () 3 | # Cookbook Name:: java 4 | # Recipe:: openjdk 5 | # 6 | # Copyright 2010-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 | version = node['java']['jdk_version'] 21 | java_home = node['java']['java_home'] 22 | java_home_parent = File.dirname java_home 23 | jdk_home = "" 24 | 25 | pkgs = value_for_platform( 26 | ["centos","redhat","fedora"] => { 27 | "default" => ["java-1.#{version}.0-openjdk","java-1.#{version}.0-openjdk-devel"] 28 | }, 29 | ["arch","freebsd"] => { 30 | "default" => ["openjdk#{version}"] 31 | }, 32 | "default" => ["openjdk-#{version}-jdk"] 33 | ) 34 | 35 | # done by special request for rberger 36 | ruby_block "set-env-java-home" do 37 | block do 38 | ENV["JAVA_HOME"] = java_home 39 | end 40 | end 41 | 42 | if platform?("ubuntu","debian","redhat","centos","fedora","scientific","amazon") 43 | ruby_block "update-java-alternatives" do 44 | block do 45 | if platform?("ubuntu", "debian") and version == 6 46 | run_context = Chef::RunContext.new(node, {}) 47 | r = Chef::Resource::Execute.new("update-java-alternatives", run_context) 48 | r.command "update-java-alternatives -s java-6-openjdk" 49 | r.returns [0,2] 50 | r.run_action(:create) 51 | else 52 | # have to do this on ubuntu for version 7 because Ubuntu does 53 | # not currently set jdk 7 as the default jvm on installation 54 | require "fileutils" 55 | arch = node['kernel']['machine'] =~ /x86_64/ ? "x86_64" : "i386" 56 | Chef::Log.debug("glob is #{java_home_parent}/java*#{version}*openjdk*") 57 | jdk_home = Dir.glob("#{java_home_parent}/java*#{version}*openjdk{,[-\.]#{arch}}")[0] 58 | Chef::Log.debug("jdk_home is #{jdk_home}") 59 | # delete the symlink if it already exists 60 | if File.exists? java_home 61 | FileUtils.rm_f java_home 62 | end 63 | FileUtils.ln_sf jdk_home, java_home 64 | 65 | cmd = Chef::ShellOut.new( 66 | %Q[ update-alternatives --install /usr/bin/java java #{java_home}/bin/java 1; 67 | update-alternatives --set java #{java_home}/bin/java ] 68 | ).run_command 69 | unless cmd.exitstatus == 0 or cmd.exitstatus == 2 70 | Chef::Application.fatal!("Failed to update-alternatives for openjdk!") 71 | end 72 | end 73 | end 74 | action :nothing 75 | end 76 | end 77 | 78 | pkgs.each do |pkg| 79 | package pkg do 80 | action :install 81 | notifies :create, "ruby_block[update-java-alternatives]" if platform?("ubuntu","debian","redhat","centos","fedora","scientific","amazon") 82 | end 83 | end 84 | -------------------------------------------------------------------------------- /recipes/oracle.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Bryan W. Berry () 3 | # Cookbook Name:: java 4 | # Recipe:: oracle 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 | 21 | java_home = node['java']["java_home"] 22 | arch = node['java']['arch'] 23 | jdk_version = node['java']['jdk_version'] 24 | 25 | #convert version number to a string if it isn't already 26 | if jdk_version.instance_of? Fixnum 27 | jdk_version = jdk_version.to_s 28 | end 29 | 30 | case jdk_version 31 | when "6" 32 | tarball_url = node['java']['jdk']['6'][arch]['url'] 33 | tarball_checksum = node['java']['jdk']['6'][arch]['checksum'] 34 | when "7" 35 | tarball_url = node['java']['jdk']['7'][arch]['url'] 36 | tarball_checksum = node['java']['jdk']['7'][arch]['checksum'] 37 | end 38 | 39 | ruby_block "set-env-java-home" do 40 | block do 41 | ENV["JAVA_HOME"] = java_home 42 | end 43 | end 44 | 45 | java_ark "jdk" do 46 | url tarball_url 47 | checksum tarball_checksum 48 | app_home java_home 49 | bin_cmds ["java"] 50 | action :install 51 | end 52 | 53 | -------------------------------------------------------------------------------- /recipes/oracle_i386.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Bryan W. Berry () 3 | # Cookbook Name:: java 4 | # Recipe:: oracle_i386 5 | # 6 | # Copyright 2010-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 | java_home = node['java']["java_home"] 21 | 22 | case node['java']['jdk_version'] 23 | when "6" 24 | tarball_url = node['java']['jdk']['6']['i586']['url'] 25 | tarball_checksum = node['java']['jdk']['6']['i586']['checksum'] 26 | when "7" 27 | tarball_url = node['java']['jdk']['7']['i586']['url'] 28 | tarball_checksum = node['java']['jdk']['7']['i586']['checksum'] 29 | end 30 | 31 | ruby_block "set-env-java-home" do 32 | block do 33 | ENV["JAVA_HOME"] = java_home 34 | end 35 | end 36 | 37 | yum_package "glibc" do 38 | arch "i686" 39 | # provider Chef::Provider::Package::Yum 40 | end 41 | 42 | java_ark "jdk-alt" do 43 | url tarball_url 44 | checksum tarball_checksum 45 | app_home java_home 46 | default false 47 | action :install 48 | end 49 | -------------------------------------------------------------------------------- /resources/ark.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Bryan W. Berry () 3 | # Cookbook Name:: java 4 | # Resource:: 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 | actions :install, :remove 21 | 22 | attribute :url, :regex => /^http:\/\/.*(tar.gz|bin|zip)$/, :default => nil 23 | attribute :mirrorlist, :kind_of => Array, :default => nil 24 | attribute :checksum, :regex => /^[a-zA-Z0-9]{64}$/, :default => nil 25 | attribute :app_home, :kind_of => String, :default => nil 26 | attribute :app_home_mode, :kind_of => Integer, :default => 0755 27 | attribute :bin_cmds, :kind_of => Array, :default => nil 28 | attribute :owner, :default => "root" 29 | attribute :default, :equal_to => [true, false], :default => true 30 | 31 | # we have to set default for the supports attribute 32 | # in initializer since it is a 'reserved' attribute name 33 | def initialize(*args) 34 | super 35 | @action = :install 36 | @supports = {:report => true, :exception => true} 37 | end 38 | --------------------------------------------------------------------------------