├── files └── .gitignore ├── spec ├── spec_helper.rb ├── acceptance │ ├── nodesets │ │ ├── debian8.yml │ │ ├── centos67.yml │ │ └── default.yml │ ├── jdk7_spec.rb │ ├── jre8_spec.rb │ └── jdk8_spec.rb ├── spec_helper_acceptance.rb └── classes │ └── jdk_oracle_package_spec.rb ├── .fixtures.yml ├── LICENSE ├── .travis.yml ├── Modulefile ├── Gemfile ├── Rakefile ├── .gitignore ├── metadata.json ├── manifests ├── init.pp ├── install.pp └── suse.pp └── README.md /files/.gitignore: -------------------------------------------------------------------------------- 1 | jdk-*-linux-*.tar.gz 2 | jdr-*-linux-*.tar.gz 3 | 4 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'puppetlabs_spec_helper/module_spec_helper' 3 | 4 | RSpec.configure do |config| 5 | config.expose_current_running_example_as :example 6 | end 7 | -------------------------------------------------------------------------------- /.fixtures.yml: -------------------------------------------------------------------------------- 1 | fixtures: 2 | symlinks: 3 | jdk_oracle: "#{source_dir}" 4 | stdlib: "#{source_dir}/puppetlabs-stdlib" 5 | archive: "#{source_dir}/puppet-archive" 6 | alternatives: "#{source_dir}/puppet-alternatives" 7 | repositories: 8 | stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib.git" 9 | archive: "https://github.com/voxpupuli/puppet-archive.git" 10 | alternatives: "https://github.com/voxpupuli/puppet-alternatives.git" -------------------------------------------------------------------------------- /spec/acceptance/nodesets/debian8.yml: -------------------------------------------------------------------------------- 1 | # module_root/spec/acceptance/nodesets/debian8.yml 2 | HOSTS: 3 | debian8: 4 | platform: debian-8-amd64 5 | image: debian:8 6 | hypervisor: docker 7 | docker_preserve_image: true 8 | roles: 9 | - agent 10 | - default 11 | docker_image_commands: 12 | - 'apt-get update && apt-get -y install puppet curl' 13 | proxyurl: False 14 | CONFIG: 15 | type: foss 16 | log_level: info 17 | masterless: true 18 | ssh: 19 | password: root 20 | auth_methods: ["password"] -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2013 Tyler Walters 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | rvm: 3 | - 2.1.1 4 | cache: bundler 5 | bundler_args: "--jobs=3 --retry=3 --without=development" 6 | before_script: bundle exec puppet --version 7 | script: bundle exec rake test 8 | env: 9 | - PUPPET_VERSION='~> 3.8.7' 10 | - PUPPET_VERSION='~> 4.7.0' 11 | matrix: 12 | include: 13 | - rvm: default 14 | sudo: required 15 | services: docker 16 | env: BEAKER_set=centos67 BEAKER_debug=true 17 | script: bundle exec rake spec_prep beaker 18 | - rvm: default 19 | sudo: required 20 | services: docker 21 | env: BEAKER_set=debian8 BEAKER_debug=true 22 | script: bundle exec rake spec_prep beaker -------------------------------------------------------------------------------- /Modulefile: -------------------------------------------------------------------------------- 1 | name 'tylerwalts-jdk_oracle' 2 | version '2.0.0' 3 | source 'https://github.com/tylerwalts/puppet-jdk_oracle' 4 | author 'tylerwalts' 5 | license 'Apache License, Version 2.0' 6 | summary 'Module for automating Oracle JDK download and installation' 7 | description 'Module for automating Oracle JDK download and installation, which does not have a dependency on a human download task, file share or centralized architecture design. It fetches the installer binary from the target server, for the target server. This approach assumes that automation is more valuable than bandwidth.' 8 | project_page 'https://github.com/tylerwalts/puppet-jdk_oracle' 9 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source ENV['GEM_SOURCE'] || 'https://rubygems.org' 2 | 3 | puppetversion = ENV.key?('PUPPET_VERSION') ? ENV['PUPPET_VERSION'] : ['>= 3.3'] 4 | gem 'metadata-json-lint' 5 | gem 'puppet', puppetversion 6 | gem 'puppetlabs_spec_helper', '>= 1.0.0' 7 | gem 'puppet-lint', '>= 1.0.0' 8 | gem 'facter', '>= 1.7.0' 9 | gem 'rspec' 10 | gem 'rspec-puppet' 11 | gem 'beaker', '=2.51.0' 12 | gem 'beaker-rspec' 13 | gem 'serverspec' 14 | gem 'pry' 15 | 16 | # rspec must be v2 for ruby 1.8.7 17 | if RUBY_VERSION >= '1.8.7' && RUBY_VERSION < '1.9' 18 | gem 'rspec', '~> 2.0' 19 | gem 'rake', '~> 10.0' 20 | else 21 | # rubocop requires ruby >= 1.9 22 | gem 'rubocop' 23 | end 24 | -------------------------------------------------------------------------------- /spec/acceptance/nodesets/centos67.yml: -------------------------------------------------------------------------------- 1 | # module_root/spec/acceptance/nodesets/centos67.yml 2 | HOSTS: 3 | centos67: 4 | platform: el-6-x84_64 5 | image: centos:6.7 6 | hypervisor: docker 7 | docker_preserve_image: true 8 | roles: 9 | - agent 10 | - default 11 | docker_image_commands: 12 | - 'yum -y install wget' 13 | - 'wget http://yum.puppetlabs.com/puppetlabs-release-pc1-el-6.noarch.rpm' 14 | - 'rpm -Uvh puppetlabs-release-pc1-el-6.noarch.rpm' 15 | - 'yum -y install puppet-agent' 16 | proxyurl: False 17 | CONFIG: 18 | type: foss 19 | log_level: info 20 | masterless: true 21 | ssh: 22 | password: root 23 | auth_methods: ["password"] -------------------------------------------------------------------------------- /spec/acceptance/nodesets/default.yml: -------------------------------------------------------------------------------- 1 | # module_root/spec/acceptance/nodesets/default.yml 2 | HOSTS: 3 | centos67: 4 | platform: el-6-x84_64 5 | image: centos:6.7 6 | hypervisor: docker 7 | docker_preserve_image: true 8 | roles: 9 | - agent 10 | - default 11 | docker_image_commands: 12 | - 'yum -y install wget' 13 | - 'wget http://yum.puppetlabs.com/puppetlabs-release-pc1-el-6.noarch.rpm' 14 | - 'rpm -Uvh puppetlabs-release-pc1-el-6.noarch.rpm' 15 | - 'yum -y install puppet-agent' 16 | proxyurl: False 17 | debian8: 18 | platform: debian-8-amd64 19 | image: debian:8 20 | hypervisor: docker 21 | docker_preserve_image: true 22 | roles: 23 | - agent 24 | docker_image_commands: 25 | - 'apt-get update && apt-get -y install puppet' 26 | CONFIG: 27 | type: foss 28 | log_level: info 29 | masterless: true 30 | ssh: 31 | password: root 32 | auth_methods: ["password"] 33 | 34 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'puppetlabs_spec_helper/rake_tasks' 2 | require 'puppet-lint/tasks/puppet-lint' 3 | require 'metadata-json-lint/rake_task' 4 | 5 | if RUBY_VERSION >= '1.9' 6 | require 'rubocop/rake_task' 7 | RuboCop::RakeTask.new 8 | end 9 | 10 | PuppetLint.configuration.send('disable_80chars') 11 | PuppetLint.configuration.relative = true 12 | PuppetLint.configuration.ignore_paths = ['spec/**/*.pp', 'pkg/**/*.pp', 'vendor/**/**'] 13 | 14 | desc 'Validate manifests, templates, and ruby files' 15 | 16 | task :validate do 17 | Dir['manifests/**/*.pp'].each do |manifest| 18 | sh "puppet parser validate --noop #{manifest}" 19 | end 20 | 21 | Dir['spec/**/*.rb', 'lib/**/*.rb'].each do |ruby_file| 22 | sh "ruby -c #{ruby_file}" unless ruby_file =~ %r{spec/fixtures} 23 | end 24 | Dir['templates/**/*.erb'].each do |template| 25 | sh "erb -P -x -T '-' #{template} | ruby -c" 26 | end 27 | end 28 | 29 | desc 'Run metadata_lint, lint, validate, and spec tests.' 30 | task :test do 31 | [:metadata_lint, :lint, :validate, :spec].each do |test| 32 | Rake::Task[test].invoke 33 | end 34 | end -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Default .gitignore for Ruby 2 | *.gem 3 | *.rbc 4 | .bundle 5 | .config 6 | coverage 7 | InstalledFiles 8 | lib/bundler/man 9 | pkg 10 | rdoc 11 | spec/reports 12 | test/tmp 13 | test/version_tmp 14 | tmp 15 | 16 | # YARD artifacts 17 | .yardoc 18 | _yardoc 19 | doc/ 20 | 21 | # Vim 22 | *.swp 23 | 24 | # OS X 25 | .DS_Store 26 | 27 | # Puppet 28 | coverage/ 29 | spec/fixtures/modules/* 30 | spec/fixtures/manifests/* 31 | Gemfile.lock 32 | 33 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm 34 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 35 | 36 | # User-specific stuff: 37 | .idea/workspace.xml 38 | .idea/tasks.xml 39 | .idea/dictionaries 40 | .idea/vcs.xml 41 | .idea/jsLibraryMappings.xml 42 | 43 | # Sensitive or high-churn files: 44 | .idea/dataSources.ids 45 | .idea/dataSources.xml 46 | .idea/dataSources.local.xml 47 | .idea/sqlDataSources.xml 48 | .idea/dynamic.xml 49 | .idea/uiDesigner.xml 50 | 51 | # Gradle: 52 | .idea/gradle.xml 53 | .idea/libraries 54 | 55 | # Mongo Explorer plugin: 56 | .idea/mongoSettings.xml 57 | 58 | ## File-based project format: 59 | *.iws 60 | 61 | ## Plugin-specific files: 62 | 63 | # IntelliJ 64 | /out/ 65 | 66 | # mpeltonen/sbt-idea plugin 67 | .idea_modules/ 68 | 69 | # JIRA plugin 70 | atlassian-ide-plugin.xml 71 | 72 | # Crashlytics plugin (for Android Studio and IntelliJ) 73 | com_crashlytics_export_strings.xml 74 | crashlytics.properties 75 | crashlytics-build.properties 76 | fabric.properties 77 | 78 | .idea/ 79 | *.iml 80 | 81 | log/* 82 | 83 | junit/* 84 | -------------------------------------------------------------------------------- /metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tylerwalts-jdk_oracle", 3 | "version": "2.0.0", 4 | "author": "tylerwalts", 5 | "summary": "Module for automating Oracle JDK download and installation", 6 | "license": "Apache-2.0", 7 | "source": "https://github.com/tylerwalts/puppet-jdk_oracle", 8 | "project_page": "https://github.com/tylerwalts/puppet-jdk_oracle", 9 | "issues_url": "https://github.com/tylerwalts/puppet-jdk_oracle/issues", 10 | "tags": [ 11 | "java", 12 | "oracle", 13 | "jdk" 14 | ], 15 | "operatingsystem_support": [ 16 | { 17 | "operatingsystem": "RedHat", 18 | "operatingsystemrelease": [ 19 | "5.0", 20 | "6.0" 21 | ] 22 | }, 23 | { 24 | "operatingsystem": "Amazon", 25 | "operatingsystemrelease": [ 26 | "2013", 27 | "2014", 28 | "2015" 29 | ] 30 | }, 31 | { 32 | "operatingsystem": "Ubuntu", 33 | "operatingsystemrelease": [ 34 | "13.10", 35 | "12.04", 36 | "10.04" 37 | ] 38 | }, 39 | { 40 | "operatingsystem": "Mint", 41 | "operatingsystemrelease": [ 42 | "17.2" 43 | ] 44 | } 45 | ], 46 | "description": "Module for automating Oracle JDK download and installation, which does not have a dependency on a human download task, file share or centralized architecture design. It fetches the installer binary from the target server, for the target server. This approach assumes that automation is more valuable than bandwidth.", 47 | "dependencies": [ 48 | {"name":"puppetlabs-stdlib","version_requirement":">= 1.0.0"}, 49 | {"name":"puppet-archive","version_requirement":">= 1.0.0"}, 50 | {"name":"puppet-alternatives","version_requirement":">= 1.0.0"} 51 | ] 52 | } 53 | -------------------------------------------------------------------------------- /spec/spec_helper_acceptance.rb: -------------------------------------------------------------------------------- 1 | require 'beaker-rspec' 2 | require 'pry' 3 | require 'pp' 4 | 5 | RSpec.configure do |c| 6 | module_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) 7 | 8 | c.formatter = :documentation 9 | 10 | c.before :suite do 11 | # Install module to all hosts 12 | hosts.each do |host| 13 | # install_puppet_agent_on(host, { :puppet_gem_version => '3.8.7', :default_action => 'gem_install'}) 14 | config = { 15 | 'main' => { 16 | 'logdir' => '/var/log/puppet', 17 | 'vardir' => '/var/lib/puppet', 18 | 'ssldir' => '/var/lib/puppet/ssl', 19 | 'rundir' => '/var/run/puppet', 20 | 'basemodulepath' => '/etc/puppet/environments/production/modules' 21 | }, 22 | 'agent' => { 23 | 'environment' => 'production', 24 | 'hiera_config' => '/etc/puppet/hiera.yaml', 25 | 'environmentpath' => '/etc/puppet/environments', 26 | 'strict_variables' => 'true' 27 | } 28 | } 29 | configure_puppet_on(host, config) 30 | 31 | on host, 'mkdir -p /etc/puppet/environments/production/{modules,hieradata,manifests}/' 32 | install_dev_puppet_module_on(host, :source => module_root, 33 | :module_name => 'jdk_oracle', 34 | :target_module_path => '/etc/puppet/environments/production/modules/') 35 | # install all modules from fixtures modules directory (spec tests) 36 | Dir.foreach(module_root + '/spec/fixtures/modules') do |mod| 37 | if not mod.start_with?('.') 38 | install_dev_puppet_module_on(host, :source => module_root + '/spec/fixtures/modules/' + mod, 39 | :module_name => mod, 40 | :target_module_path => '/etc/puppet/environments/production/modules/') 41 | end 42 | end 43 | 44 | end 45 | end 46 | end -------------------------------------------------------------------------------- /spec/classes/jdk_oracle_package_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'jdk_oracle' do 4 | let(:facts) { { 5 | :operatingsystem => 'CentOS', 6 | :osfamily => 'RedHat' 7 | }} 8 | context 'with default values for all parameters' do 9 | it { should contain_jdk_oracle__install('jdk_oracle')} 10 | it { is_expected.to contain_Archive('/opt/jdk-8u121-linux-x64.tar.gz') 11 | .with_source('http://download.oracle.com/otn-pub/java/jdk/8u121-b13/e9e7ea248e2c4826b92b3f075a80e441/jdk-8u121-linux-x64.tar.gz') 12 | .with_extract_path('/opt/jdk1.8.0_121/..') 13 | } 14 | 15 | context 'with jce => true' do 16 | let(:params) { { 17 | :jce => true 18 | }} 19 | it { is_expected.to contain_Archive('/opt/jce_policy-8.zip') 20 | .with_source('http://download.oracle.com/otn-pub/java/jce/8/jce_policy-8.zip') 21 | .with_extract_command('unzip -d /opt/jdk1.8.0_121/jre/lib/security -o -j %s') 22 | } 23 | end 24 | context 'with custom download url ' do 25 | let(:params) { { 26 | :download_url => 'http://onpremise_webhost/java' 27 | }} 28 | it { is_expected.to contain_Archive('/opt/jdk-8u121-linux-x64.tar.gz') 29 | .with_source('http://onpremise_webhost/java/jdk/8u121-b13/e9e7ea248e2c4826b92b3f075a80e441/jdk-8u121-linux-x64.tar.gz') 30 | } 31 | end 32 | context 'with proxy_host' do 33 | let(:params) { { 34 | :proxy_host => 'http://proxy_host:3128' 35 | }} 36 | it { is_expected.to contain_Archive('/opt/jdk-8u121-linux-x64.tar.gz') 37 | .with_proxy_server('http://proxy_host:3128') 38 | } 39 | end 40 | context 'with custom installation path' do 41 | let(:params) { { 42 | :install_dir => '/path/to/installation/directory' 43 | }} 44 | it { is_expected.to contain_Archive('/path/to/installation/directory/jdk-8u121-linux-x64.tar.gz') 45 | .with_extract_path('/path/to/installation/directory/jdk1.8.0_121/..') 46 | } 47 | end 48 | context 'with build and update number' do 49 | let(:params) { { 50 | :version_update => '102', 51 | :version_build => '14' 52 | }} 53 | it { is_expected.to contain_Archive('/opt/jdk-8u102-linux-x64.tar.gz') 54 | .with_source('http://download.oracle.com/otn-pub/java/jdk/8u102-b14/jdk-8u102-linux-x64.tar.gz') 55 | .with_extract_path('/opt/jdk1.8.0_102/..') 56 | } 57 | end 58 | end 59 | end -------------------------------------------------------------------------------- /spec/acceptance/jdk7_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | # module_root/spec/acceptance/jdk7_spec.rb 3 | require 'spec_helper_acceptance' 4 | 5 | describe 'jdk_oracle to install default jdk7 with JCE' do 6 | hosts.each do |node| 7 | if node['proxyurl'] 8 | str_manifest = <<-EOS 9 | class { 'jdk_oracle': 10 | proxy_host => '#{node['proxyurl']}', 11 | version => '7', 12 | version_update => '67', 13 | version_build => '01', 14 | default_java => true, 15 | install_dir => '/usr/java', 16 | jce => true 17 | } 18 | EOS 19 | else 20 | str_manifest = <<-EOS 21 | class { 'jdk_oracle': 22 | proxy_host => undef, 23 | version => '7', 24 | version_update => '67', 25 | version_build => '01', 26 | default_java => true, 27 | install_dir => '/usr/java', 28 | jce => true 29 | } 30 | EOS 31 | end 32 | # puts full_manifest 33 | let(:manifest) { 34 | str_manifest 35 | } 36 | 37 | it 'should run without errors' do 38 | result = apply_manifest_on(node, manifest, :catch_failures => true, :debug => true) 39 | expect(result.exit_code).to eq 2 40 | end 41 | 42 | if node['platform'] =~ /debian/ 43 | alternatives_cmd = 'update-alternatives' 44 | else 45 | alternatives_cmd = 'alternatives' 46 | end 47 | # default install with no args 48 | 49 | context'should install jdk7u67 in /usr/java' do 50 | describe file('/usr/java/jdk1.7.0_67') do 51 | it { should be_directory } 52 | it { should be_owned_by 'root' } 53 | it { should be_grouped_into 'root' } 54 | it { should be_readable.by('others') } 55 | end 56 | 57 | describe 'Source file should be removed' do 58 | describe file('/usr/java/jdk-7u67-linux-x64.tar.gz') do 59 | it { should_not exist } 60 | end 61 | end 62 | 63 | it 'Should set a new default alternatives' do 64 | show_result = shell("#{alternatives_cmd} --display java | grep currently | awk '{ print $5 }'") 65 | expect(show_result.stdout).to match /\/usr\/java\/jdk1.7.0_67\/bin\/java/ 66 | end 67 | it 'Should setup a new alternatives option' do 68 | show_result = shell("#{alternatives_cmd} --display java | grep ^/usr/java/jdk1.7.0_67/bin/java") 69 | expect(show_result.stdout).to match /\/usr\/java\/jdk1.7.0_67\/bin\/java/ 70 | end 71 | 72 | describe 'Java profile.d file should be set to newly default java installation' do 73 | describe file('/etc/profile.d/java.sh') do 74 | it { should exist } 75 | its(:content) { should match /export JAVA_HOME=\/usr\/java\/jdk1.7.0_67; PATH=\$\{PATH\}:\/usr\/java\/jdk1.7.0_67\/bin/ } 76 | end 77 | end 78 | describe 'Should setup Java Crypto Extentions' do 79 | shell('cat < /Test.java 80 | import javax.crypto.Cipher; 81 | 82 | class Test { 83 | public static void main(String[] args) { 84 | try { 85 | int maxKeyLen = Cipher.getMaxAllowedKeyLength("AES"); 86 | System.out.println(maxKeyLen); 87 | } catch (Exception e){ 88 | System.out.println("Sad world :("); 89 | } 90 | } 91 | } 92 | EOF') 93 | describe command('javac /Test.java') do 94 | its(:exit_status) { should eq 0 } 95 | end 96 | describe command('java -cp / Test') do 97 | its(:exit_status) { should eq 0 } 98 | its(:stdout) { should match /2147483647/ } 99 | end 100 | end 101 | end 102 | end 103 | end -------------------------------------------------------------------------------- /manifests/init.pp: -------------------------------------------------------------------------------- 1 | # == Class: jdk_oracle 2 | # 3 | # Installs the Oracle Java JDK, from the Oracle servers 4 | # 5 | # === Parameters 6 | # 7 | # [*version*] 8 | # String. Java Version to install 9 | # Defaults to 8. 10 | # 11 | # [*version_update*] 12 | # String. Java Version Update to install 13 | # Defaults to Defaults based on major version. 14 | # 15 | # [*version_build*] 16 | # String. Java Version build to install 17 | # Defaults to Defaults based on major version. 18 | # 19 | # [*version_hash*] 20 | # String. Hash from the Oracle download URL. Must be specified for more 21 | # current Java versions. If set to an empty string, the hash is ignored 22 | # in the URL. Defaults to an empty string, but if version_update or 23 | # version_build are set to "default", the most current hash is used. 24 | # 25 | # [* java_install_dir *] 26 | # String. Java Installation Directory 27 | # Defaults to /opt. 28 | # 29 | # [* use_cache *] 30 | # Boolean. Optionally host the installer file locally instead of fetching it each time (for faster dev & test) 31 | # The puppet cache flag is for faster local vagrant development, to 32 | # locally host the tarball from oracle instead of fetching it each time. 33 | # Defaults to false. 34 | # 35 | # [* platform *] 36 | # String. The platform to use 37 | # Defaults to x64. 38 | # 39 | # [* package *] 40 | # String. Which package to install. Can be one of the following: jdk, jre, server-jre 41 | # Defaults to jdk. 42 | # 43 | # [* jce *] 44 | # Boolean. Optionally install Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files 45 | # Defaults to false. 46 | # 47 | # [* default_java *] 48 | # Boolean. If the installed java version is linked as the default java, javac etc... 49 | # Defaults to true. 50 | # 51 | # [* ensure *] 52 | # String. Specifies if jdk should be installed or absent 53 | # Defaults to installed. 54 | # 55 | class jdk_oracle ( 56 | $version = hiera('jdk_oracle::version', '8' ), 57 | $version_update = hiera('jdk_oracle::version_update', 'default' ), 58 | $version_build = hiera('jdk_oracle::version_build', 'default' ), 59 | $install_dir = hiera('jdk_oracle::install_dir', '/opt' ), 60 | $use_cache = hiera('jdk_oracle::use_cache', false ), 61 | $cache_source = 'puppet:///modules/jdk_oracle/', 62 | $platform = hiera('jdk_oracle::platform', 'x64' ), 63 | $package = hiera('jdk_oracle::package', 'jdk' ), 64 | $jce = hiera('jdk_oracle::jce', false ), 65 | $default_java = hiera('jdk_oracle::default_java', true ), 66 | $download_url = hiera('jdk_oracle::download_url', 'http://download.oracle.com/otn-pub/java'), 67 | $proxy_host = hiera('jdk_oracle::proxy_host', false ), 68 | $version_hash = hiera('jdk_oracle::version_hash', '' ), 69 | $ensure = 'installed' 70 | ) { 71 | 72 | jdk_oracle::install { 'jdk_oracle': 73 | ensure => $ensure, 74 | version => $version, 75 | version_update => $version_update, 76 | version_build => $version_build, 77 | install_dir => $install_dir, 78 | use_cache => $use_cache, 79 | cache_source => $cache_source, 80 | platform => $platform, 81 | package => $package, 82 | jce => $jce, 83 | version_hash => $version_hash, 84 | default_java => $default_java, 85 | } 86 | 87 | if ! defined(Package['curl']) { 88 | package { 'curl': 89 | ensure => present, 90 | } 91 | } 92 | 93 | if ! defined(Package['unzip']) { 94 | package { 'unzip': 95 | ensure => present, 96 | } 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /spec/acceptance/jre8_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | # module_root/spec/acceptance/jdk8_spec.rb 3 | require 'spec_helper_acceptance' 4 | 5 | describe 'jre_oracle with default parameters plus another jre8 instance' do 6 | hosts.each do |node| 7 | if node['proxyurl'] 8 | str_manifest = <<-EOS 9 | class { 'jdk_oracle': 10 | proxy_host => '#{node['proxyurl']}', 11 | package => 'jre', 12 | } 13 | # setup a jdk instance to compile the jce tester 14 | jdk_oracle::install { 'jdk8u102': 15 | version_update => '102', 16 | version_build => '14', 17 | install_dir => '/usr/java' 18 | } 19 | jdk_oracle::install { 'jre8u102': 20 | package => 'jre', 21 | version_update => '102', 22 | version_build => '14', 23 | default_java => true, 24 | install_dir => '/usr/java' 25 | } 26 | EOS 27 | else 28 | str_manifest = <<-EOS 29 | class { 'jdk_oracle': 30 | package => 'jre', 31 | } 32 | # setup a jdk instance to compile the jce tester 33 | jdk_oracle::install { 'jdk8u102': 34 | version_update => '102', 35 | version_build => '14', 36 | install_dir => '/usr/java' 37 | } 38 | jdk_oracle::install { 'jre8u102': 39 | package => 'jre', 40 | version_update => '102', 41 | version_build => '14', 42 | default_java => true, 43 | install_dir => '/usr/java' 44 | } 45 | EOS 46 | end 47 | # puts full_manifest 48 | let(:manifest) { 49 | str_manifest 50 | } 51 | 52 | it 'should run without errors' do 53 | result = apply_manifest_on(node, manifest, :catch_failures => true, :debug => false) 54 | expect(result.exit_code).to eq 2 55 | end 56 | 57 | if node['platform'] =~ /debian/ 58 | alternatives_cmd = 'update-alternatives' 59 | else 60 | alternatives_cmd = 'alternatives' 61 | end 62 | 63 | # default install with no args 64 | 65 | context'should install jre8u11 in /opt' do 66 | describe file('/opt/jre1.8.0_11') do 67 | it { should be_directory } 68 | it { should be_owned_by 'root' } 69 | it { should be_grouped_into 'root' } 70 | it { should be_readable.by('others') } 71 | end 72 | it 'should not mess up default alternatives' do 73 | show_result = shell("#{alternatives_cmd} --display java | grep currently | awk '{ print $5 }'") 74 | expect(show_result.stdout).not_to match /\/opt\/jre1.8.0_11\/bin\/java/ 75 | end 76 | it 'Should define a new alternatives for java' do 77 | show_result = shell("#{alternatives_cmd} --display java | grep ^/opt/jre1.8.0_11/bin/java") 78 | expect(show_result.stdout).to match /\/opt\/jre1.8.0_11\/bin\/java/ 79 | end 80 | describe 'Source file should be removed' do 81 | describe file('/opt/jre-8u11-linux-x64.tar.gz') do 82 | it { should_not exist } 83 | end 84 | end 85 | end 86 | 87 | # the other install resource: 88 | context 'should install jre8u102 in /usr/java' do 89 | describe file('/usr/java/jre1.8.0_102') do 90 | it { should be_directory } 91 | it { should be_owned_by 'root' } 92 | it { should be_grouped_into 'root' } 93 | it { should be_readable.by('others') } 94 | end 95 | describe 'Source file should be removed' do 96 | describe file('/usr/java/jre-8u102-linux-x64.tar.gz') do 97 | it { should_not exist } 98 | end 99 | end 100 | it 'Should set a new default alternatives' do 101 | show_result = shell("#{alternatives_cmd} --display java | grep currently | awk '{ print $5 }'") 102 | expect(show_result.stdout).to match /\/usr\/java\/jre1.8.0_102\/bin\/java/ 103 | end 104 | it 'Should setup a new alternatives option' do 105 | show_result = shell("#{alternatives_cmd} --display java | grep ^/usr/java/jre1.8.0_102/bin/java") 106 | expect(show_result.stdout).to match /\/usr\/java\/jre1.8.0_102\/bin\/java/ 107 | end 108 | describe 'Java profile.d file should be set to newly default java installation' do 109 | describe file('/etc/profile.d/java.sh') do 110 | it { should exist } 111 | its(:content) { should match /export JAVA_HOME=\/usr\/java\/jre1.8.0_102; PATH=\$\{PATH\}:\/usr\/java\/jre1.8.0_102\/bin/ } 112 | end 113 | end 114 | end 115 | end 116 | end -------------------------------------------------------------------------------- /spec/acceptance/jdk8_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | # module_root/spec/acceptance/jdk8_spec.rb 3 | require 'spec_helper_acceptance' 4 | 5 | describe 'jdk_oracle with default parameters plus another jdk8 instance' do 6 | hosts.each do |node| 7 | if node['proxyurl'] 8 | str_manifest = <<-EOS 9 | class { 'jdk_oracle': 10 | proxy_host => '#{node['proxyurl']}' 11 | } 12 | jdk_oracle::install { 'jdk8u102': 13 | version_update => '102', 14 | version_build => '14', 15 | default_java => true, 16 | install_dir => '/usr/java', 17 | jce => true 18 | } 19 | EOS 20 | else 21 | str_manifest = <<-EOS 22 | class { 'jdk_oracle': 23 | proxy_host => undef, 24 | } 25 | jdk_oracle::install { 'jdk8u102': 26 | version_update => '102', 27 | version_build => '14', 28 | default_java => true, 29 | install_dir => '/usr/java', 30 | jce => true 31 | } 32 | EOS 33 | end 34 | # puts full_manifest 35 | let(:manifest) { 36 | str_manifest 37 | } 38 | 39 | it 'should run without errors' do 40 | result = apply_manifest_on(node, manifest, :catch_failures => true, :debug => false) 41 | expect(result.exit_code).to eq 2 42 | end 43 | 44 | if node['platform'] =~ /debian/ 45 | alternatives_cmd = 'update-alternatives' 46 | else 47 | alternatives_cmd = 'alternatives' 48 | end 49 | # default install with no args 50 | 51 | context'should install jdk8u11 in /opt' do 52 | describe file('/opt/jdk1.8.0_11') do 53 | it { should be_directory } 54 | it { should be_owned_by 'root' } 55 | it { should be_grouped_into 'root' } 56 | it { should be_readable.by('others') } 57 | end 58 | 59 | it 'should not mess up default alternatives' do 60 | show_result = shell("#{alternatives_cmd} --display java | grep currently | awk \'{ print $5 }\'") 61 | expect(show_result.stdout).not_to match /\/opt\/jdk1.8.0_11\/bin\/java/ 62 | end 63 | it 'Should define a new alternatives for java' do 64 | show_result = shell("#{alternatives_cmd} --display java | grep ^/opt/jdk1.8.0_11/bin/java") 65 | expect(show_result.stdout).to match /\/opt\/jdk1.8.0_11\/bin\/java/ 66 | end 67 | describe 'Source file should be removed' do 68 | describe file('/opt/jdk-8u11-linux-x64.tar.gz') do 69 | it { should_not exist } 70 | end 71 | end 72 | describe 'Should not setup Java Crypto Extentions' do 73 | shell('cat < /Test.java 74 | import javax.crypto.Cipher; 75 | 76 | class Test { 77 | public static void main(String[] args) { 78 | try { 79 | int maxKeyLen = Cipher.getMaxAllowedKeyLength("AES"); 80 | System.out.println(maxKeyLen); 81 | } catch (Exception e){ 82 | System.out.println("Sad world :("); 83 | } 84 | } 85 | } 86 | EOF') 87 | describe command('/opt/jdk1.8.0_11/bin/javac /Test.java') do 88 | its(:exit_status) { should eq 0 } 89 | end 90 | describe command('/opt/jdk1.8.0_11/bin/java -cp / Test') do 91 | its(:exit_status) { should eq 0 } 92 | its(:stdout) { should match /128/ } 93 | end 94 | end 95 | end 96 | 97 | # the other install resource: 98 | context 'should install jdk8u102 in /usr/java' do 99 | describe file('/usr/java/jdk1.8.0_102') do 100 | it { should be_directory } 101 | it { should be_owned_by 'root' } 102 | it { should be_grouped_into 'root' } 103 | it { should be_readable.by('others') } 104 | end 105 | describe 'Source file should be removed' do 106 | describe file('/usr/java/jdk-8u102-linux-x64.tar.gz') do 107 | it { should_not exist } 108 | end 109 | end 110 | it 'Should set a new default alternatives' do 111 | show_result = shell("#{alternatives_cmd} --display java | grep currently | awk '{ print $5 }'") 112 | expect(show_result.stdout).to match /\/usr\/java\/jdk1.8.0_102\/bin\/java/ 113 | end 114 | it 'Should setup a new alternatives option' do 115 | show_result = shell("#{alternatives_cmd} --display java | grep ^/usr/java/jdk1.8.0_102/bin/java") 116 | expect(show_result.stdout).to match /\/usr\/java\/jdk1.8.0_102\/bin\/java/ 117 | end 118 | describe 'Java profile.d file should be set to newly default java installation' do 119 | describe file('/etc/profile.d/java.sh') do 120 | it { should exist } 121 | its(:content) { should match /export JAVA_HOME=\/usr\/java\/jdk1.8.0_102; PATH=\$\{PATH\}:\/usr\/java\/jdk1.8.0_102\/bin/ } 122 | end 123 | end 124 | describe 'Should setup Java Crypto Extentions' do 125 | shell('cat < /Test.java 126 | import javax.crypto.Cipher; 127 | 128 | class Test { 129 | public static void main(String[] args) { 130 | try { 131 | int maxKeyLen = Cipher.getMaxAllowedKeyLength("AES"); 132 | System.out.println(maxKeyLen); 133 | } catch (Exception e){ 134 | System.out.println("Sad world :("); 135 | } 136 | } 137 | } 138 | EOF') 139 | describe command('javac /Test.java') do 140 | its(:exit_status) { should eq 0 } 141 | end 142 | describe command('java -cp / Test') do 143 | its(:exit_status) { should eq 0 } 144 | its(:stdout) { should match /2147483647/ } 145 | end 146 | end 147 | end 148 | end 149 | end -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # puppet-jdk_oracle 2 | 3 | ## Deprecated! 4 | 5 | As of 2017-12-20 I've decided to no longer maintain this module, and recommend the official PuppetLabs module, here: 6 | 7 | * https://github.com/puppetlabs/puppetlabs-java 8 | 9 | The folks at puppet have implemented the `java::oracle` class such that it can auto-accept the cookie and install from tarball, just like this one, and it is better maintained. 10 | 11 | Thanks to everyone who has contributed and used this module over the years! At the time of writing, this module has picked up over 56K downloads and a 4.9 quality rating on the Puppet Forge. 12 | 13 | Please reach out if you would like to take over maintenance on this module. 14 | 15 | Cheers, 16 | 17 | - Tyler 18 | 19 | ----- 20 | 21 | 22 | [![Build Status](https://travis-ci.org/tylerwalts/puppet-jdk_oracle.png?branch=master)](https://travis-ci.org/tylerwalts/puppet-jdk_oracle) 23 | 24 | ## Overview 25 | 26 | Puppet module to automate fetching and installing the Oracle JDK/JRE/Server-JRE from the Oracle-hosted download site located here: http://www.oracle.com/technetwork/java/javase/downloads/index.html 27 | 28 | _Note: By using this module you will automatically accept the Oracle agreement to download Java._ 29 | 30 | There are several puppet modules available that will help install Oracle JDK/JRE/Server-JRE, but they either use the local package manager repository, or depend on the user to manually place the Oracle Java installer in the module's file directory prior to using. This module will use wget with a cookie to automatically grab the installer from Oracle. 31 | 32 | This approach was inspired by: http://stackoverflow.com/questions/10268583/how-to-automate-download-and-instalation-of-java-jdk-on-linux 33 | 34 | ### Supported Operating Systems: 35 | * RedHat Family (RedHat, Fedora, CentOS) 36 | * Debian Family (Ubuntu) 37 | * SUSE 38 | * _This may work on other linux flavors but more testing is needed. Please send feedback!_ 39 | 40 | ### Supported Java Versions: 41 | * Java 6, 7, 8 42 | * Build versions should be specified as parameters (see below) 43 | 44 | #### Reasons you may want to use this module: 45 | 46 | 1. You do not control or trust your package repository to host the version of Oracle Java that you want. 47 | 1. You want to lock in the version that gets installed. 48 | 1. You want to use Oracle’s CDN to host the binary instead of hosting it yourself. 49 | 50 | #### Reasons why you would not want to use this module: 51 | 52 | 1. If you want to use package management (.deb, .rpm) instead of extracting a generic archive. 53 | 1. Consider schrepfler’s fork which does RPM without v6: https://github.com/schrepfler/puppet-jdk_oracle 54 | 1. If you want to rely on your package repository to host the binary, not Oracle. 55 | 1. If your target configuration server does not have access to the Internet. Assumes the server can pull it. 56 | 57 | 58 | ## Installation: 59 | 60 | ### A) Traditional: 61 | * Copy this project into your puppet modules path and rename to "jdk_oracle" 62 | 63 | ### B) Puppet Librarian: 64 | * Put this in your Puppetfile: 65 | From Forge: 66 | ``` 67 | mod "tylerwalts/jdk_oracle" 68 | ``` 69 | 70 | From Source: 71 | ``` 72 | mod "tylerwalts/jdk_oracle", 73 | :git => "git://github.com/tylerwalts/puppet-jdk_oracle.git" 74 | ``` 75 | 76 | 77 | ## Usage: 78 | 79 | ### A) Traditional: 80 | ``` 81 | include jdk_oracle 82 | ``` 83 | or 84 | ``` 85 | class { 'jdk_oracle': } 86 | ``` 87 | 88 | 89 | ### B) Hiera: 90 | config.json: 91 | ``` 92 | { 93 | classes":[ 94 | "jdk_oracle" 95 | ] 96 | } 97 | ``` 98 | OR 99 | config.yaml: 100 | ``` 101 | --- 102 | classes: 103 | - "jdk_oracle" 104 | jdk_oracle::version: "6" 105 | ``` 106 | 107 | site.pp: 108 | ``` 109 | hiera_include("classes", []) 110 | ``` 111 | 112 | 113 | ## Parameters: 114 | ### Class jdk_oracle 115 | * version 116 | * Java Version to install 117 | * version_update 118 | * Java Version update to install 119 | * version_build 120 | * Java Version build to install 121 | * version_hash 122 | * The hash in more current Oracle download URLs 123 | * install_dir 124 | * Java Installation Directory 125 | * use_cache 126 | * Optionally host the installer file locally instead of fetching it each time, for faster dev & test 127 | * platform 128 | * The platform to use 129 | * package 130 | * The package to install. Can be one of the following: jdk, jre, server-jre 131 | * jce 132 | * Boolean to optionally install Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files (Java 8 only) 133 | * default_java 134 | * Boolean to indicate if the installed java version is linked as the default java, javac etc. Defaults to true. 135 | * ensure 136 | * Boolean to disable anything from happening (absent/removal not supported yet) 137 | * download_url 138 | * string: the download base url to use. default to oracle cdn. should contain the jdk directory. eg : https://custom_host -> https://custom_host/jdk/8u11-b12/jdk-8u11-linux-x64.tar.gz 139 | * proxy_host 140 | * a proxy host use. Default to undef. 141 | 142 | ### jdk_oracle::install 143 | Basicaly the same option as class jdk_oracle. 144 | * version 145 | * Java Version to install 146 | * version_update 147 | * Java Version update to install 148 | * version_build 149 | * Java Version build to install 150 | * version_hash 151 | * The hash in more current Oracle download URLs 152 | * install_dir 153 | * Java Installation Directory 154 | * use_cache 155 | * Optionally host the installer file locally instead of fetching it each time, for faster dev & test 156 | * platform 157 | * The platform to use 158 | * package 159 | * The package to install. Can be one of the following: jdk, jre, server-jre 160 | * jce 161 | * Boolean to optionally install Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files (Java 8 only) 162 | * default_java 163 | * Boolean to indicate if the installed java version is linked as the default java, javac etc. Defaults to true. 164 | * create_symlink: 165 | * Boolean to indicate if we have to create a symlink of java_home to the default java_home. Defaults to true. 166 | * proxy 167 | 168 | ## Example Usage. 169 | 170 | to install the default jdk8u11 plus jdk8u102 as default with JCE with default parameters : 171 | 172 | ```puppet 173 | class { 'jdk_oracle': 174 | jce => true 175 | } 176 | 177 | jdk_oracle::install { 'jdk_11u102': 178 | version_update => '102', 179 | version_build => '14', 180 | default_java => true, 181 | jce => true, 182 | install_dir => '/usr/java' 183 | } 184 | ``` 185 | 186 | to install only jdk8u102 as default with jce, with custom repository and proxy 187 | ```puppet 188 | class { 'jdk_oracle': 189 | jce => true, 190 | default => true, 191 | download_url => 'https://nexus.corp/java', 192 | proxy_host => 'http://proxyhost:3128', 193 | version_update => '102', 194 | version_build => '14', 195 | } 196 | ``` 197 | 198 | 199 | 200 | 201 | -------------------------------------------------------------------------------- /manifests/install.pp: -------------------------------------------------------------------------------- 1 | define jdk_oracle::install( 2 | $version = '8', 3 | $version_update = 'default', 4 | $version_build = 'default', 5 | $install_dir = '/opt', 6 | $use_cache = false, 7 | $cache_source = 'puppet:///modules/jdk_oracle/', 8 | $platform = 'x64', 9 | $package = 'jdk', 10 | $jce = false, 11 | $default_java = true, 12 | $create_symlink = true, 13 | $version_hash = '', 14 | $ensure = 'installed', 15 | ) { 16 | 17 | $default_8_update = '121' 18 | $default_8_build = '13' 19 | $default_8_hash = 'e9e7ea248e2c4826b92b3f075a80e441' 20 | $default_7_update = '80' 21 | $default_7_build = '15' 22 | $default_6_update = '45' 23 | $default_6_build = '06' 24 | 25 | if $ensure == 'installed' { 26 | # Set default exec path for this module 27 | Exec { path => ['/usr/bin', '/usr/sbin', '/bin'] } 28 | 29 | case $platform { 30 | 'x64': { $plat_filename = 'x64' } 31 | 'x86': { $plat_filename = 'i586' } 32 | default: { fail("Unsupported platform: ${platform}. Implement me?") } 33 | } 34 | 35 | if $package != 'jdk' and $package != 'server-jre' and $package != 'jre' { 36 | fail("Unsupported package: ${package}. Implement me?") 37 | } 38 | 39 | $package_home = $package ? { 40 | 'jre' => 'jre', 41 | default => 'jdk' 42 | } 43 | case $version { 44 | '8': { 45 | if ($version_update != 'default') { 46 | $version_u = $version_update 47 | } else { 48 | $version_u = $default_8_update 49 | } 50 | if ($version_build != 'default'){ 51 | $version_b = $version_build 52 | } else { 53 | $version_b = $default_8_build 54 | } 55 | if (($version_update == 'default' or $version_build == 'default') and ($version_hash == '')) { 56 | # If either version parts are default and hash is empty, 57 | # Assume, that the user means the default value 58 | $version_h = $default_8_hash 59 | } elsif ($version_hash != 'default') { 60 | $version_h = $version_hash 61 | } else { 62 | $version_h = $default_8_hash 63 | } 64 | $pkg_name = "${package}-${version}u${version_u}-linux-${plat_filename}.tar.gz" 65 | # useful to set alternatives priority 66 | $int_version = "1${version}0${version_u}" 67 | if ($version_h != '') { 68 | $java_download_uri = "${jdk_oracle::download_url}/jdk/${version}u${version_u}-b${version_b}/${version_h}/${pkg_name}" 69 | } else { 70 | $java_download_uri = "${jdk_oracle::download_url}/jdk/${version}u${version_u}-b${version_b}/${pkg_name}" 71 | } 72 | 73 | $java_home = "${install_dir}/${package_home}1.${version}.0_${version_u}" 74 | $jdc_download_uri = "${jdk_oracle::download_url}/jce/8/jce_policy-8.zip" 75 | } 76 | '7': { 77 | if ($version_update != 'default'){ 78 | $version_u = $version_update 79 | } else { 80 | $version_u = $default_7_update 81 | } 82 | if ($version_build != 'default'){ 83 | $version_b = $version_build 84 | } else { 85 | $version_b = $default_7_build 86 | } 87 | $pkg_name = "${package}-${version}u${version_u}-linux-${plat_filename}.tar.gz" 88 | # useful to set alternatives priority 89 | $int_version = "1${version}0${version_u}" 90 | $java_download_uri = "${jdk_oracle::download_url}/jdk/${version}u${version_u}-b${version_b}/${pkg_name}" 91 | $java_home = "${install_dir}/${package_home}1.${version}.0_${version_u}" 92 | $jdc_download_uri = "${jdk_oracle::download_url}/jce/7/UnlimitedJCEPolicyJDK7.zip" 93 | } 94 | '6': { 95 | if ($version_update != 'default'){ 96 | $version_u = $version_update 97 | } else { 98 | $version_u = $default_6_update 99 | } 100 | if ($version_build != 'default'){ 101 | $version_b = $version_build 102 | } else { 103 | $version_b = $default_6_build 104 | } 105 | # not updated to use download url, who's using jdk 6 anyways ? 106 | $java_download_uri = "https://edelivery.oracle.com/otn-pub/java/jdk/${version}u${version_u}-b${version_b}/${package}-${version}u${version_u}-linux-${plat_filename}.bin" 107 | $java_home = "${install_dir}/${package_home}1.${version}.0_${version_u}" 108 | $jdc_download_uri = 'http://download.oracle.com/otn-pub/java/jce_policy/6/jce_policy-6.zip' 109 | } 110 | default: { 111 | fail("Unsupported version: ${version}. Implement me?") 112 | } 113 | } 114 | 115 | if !defined(File[$install_dir]) { 116 | file { $install_dir: 117 | ensure => directory, 118 | } 119 | } 120 | 121 | $installer_filename = $pkg_name 122 | 123 | if ( $use_cache ){ 124 | file { "${install_dir}/${installer_filename}": 125 | source => "${cache_source}${installer_filename}", 126 | require => File[$install_dir], 127 | } 128 | -> exec { "get_${package}_installer_${version}": 129 | cwd => $install_dir, 130 | creates => "${install_dir}/${package}_from_cache", 131 | command => "touch ${package}_from_cache", 132 | } 133 | } else { 134 | if ( $version in [ '7', '8' ] ) { 135 | archive { "${install_dir}/${installer_filename}": 136 | ensure => present, 137 | extract => true, 138 | source => $java_download_uri, 139 | proxy_server => $jdk_oracle::proxy_host, 140 | cookie => 'oraclelicense=accept-securebackup-cookie', 141 | extract_path => "${java_home}/..", 142 | extract_flags => '-xzof', 143 | creates => "${java_home}/bin/java", 144 | cleanup => true, 145 | require => File[$java_home], 146 | user => 'root', 147 | group => 'root' 148 | } 149 | } elsif ( $version == '6' ) { 150 | exec { "get_${package}_installer_${version}": 151 | cwd => $install_dir, 152 | creates => "${install_dir}/${installer_filename}", 153 | command => "wget -c --no-cookies --no-check-certificate --header \"Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com\" --header \"Cookie: oraclelicense=accept-securebackup-cookie\" \"${java_download_uri}\" -O ${installer_filename}", 154 | timeout => 600, 155 | require => Package['wget'], 156 | } 157 | exec { "extract_${package}_${version}": 158 | cwd => "${install_dir}/", 159 | command => "${install_dir}/${installer_filename}", 160 | creates => $java_home, 161 | require => File["${install_dir}/${installer_filename}"], 162 | } 163 | file { "${install_dir}/${installer_filename}": 164 | mode => '0755', 165 | require => Exec["get_${package}_installer_${version}"], 166 | } 167 | 168 | if ! defined(Package['wget']) { 169 | package { 'wget': 170 | ensure => present, 171 | } 172 | } 173 | 174 | } 175 | } 176 | # Ensure that files belong to root 177 | file { $java_home: 178 | ensure => directory, 179 | owner => root, 180 | group => root, 181 | } 182 | 183 | if ($package == 'jdk' ) { 184 | alternative_entry { "${java_home}/bin/javac": 185 | ensure => present, 186 | altlink => '/usr/bin/javac', 187 | altname => 'javac', 188 | priority => $int_version, 189 | require => Archive["${install_dir}/${installer_filename}"] 190 | } 191 | alternative_entry { "${java_home}/bin/jar": 192 | ensure => present, 193 | altlink => '/usr/bin/jar', 194 | altname => 'jar', 195 | priority => $int_version, 196 | require => Archive["${install_dir}/${installer_filename}"] 197 | } 198 | } 199 | alternative_entry { "${java_home}/bin/java": 200 | ensure => present, 201 | altlink => '/usr/bin/java', 202 | altname => 'java', 203 | priority => $int_version, 204 | require => Archive["${install_dir}/${installer_filename}"] 205 | } 206 | # Set links depending on osfamily or operating system fact 207 | case $::osfamily { 208 | 'RedHat', 'Linux', 'debian': { 209 | if ( $default_java ) { 210 | alternatives { 'java': 211 | path => "${java_home}/bin/java", 212 | require => Alternative_entry["${java_home}/bin/java"] 213 | } 214 | if $package == 'jdk' { 215 | alternatives { 'javac': 216 | path => "${java_home}/bin/javac", 217 | require => Alternative_entry["${java_home}/bin/javac"] 218 | } 219 | alternatives { 'jar': 220 | path => "${java_home}/bin/jar", 221 | require => Alternative_entry["${java_home}/bin/jar"] 222 | } 223 | } 224 | file { '/etc/profile.d/java.sh': 225 | ensure => present, 226 | content => "export JAVA_HOME=${java_home}; PATH=\${PATH}:${java_home}/bin", 227 | require => Alternatives['java'], 228 | } 229 | if ( $create_symlink ) { 230 | file { "${install_dir}/java_home": 231 | ensure => link, 232 | target => $java_home, 233 | require => Archive["${install_dir}/${installer_filename}"] 234 | } 235 | file { "${install_dir}/${package}-${version}": 236 | ensure => link, 237 | target => $java_home, 238 | require => Archive["${install_dir}/${installer_filename}"] 239 | } 240 | } 241 | } 242 | } 243 | 'Suse': { 244 | if ( $default_java ) { 245 | include 'jdk_oracle::suse' 246 | } 247 | } 248 | default: { fail("Unsupported OS: ${::osfamily}. Implement me?") } 249 | } 250 | if ( $jce ) { 251 | $jce_filename = basename($jdc_download_uri) 252 | $jce_dir = $version ? { 253 | '8' => 'UnlimitedJCEPolicyJDK8', 254 | '7' => 'UnlimitedJCEPolicy', 255 | '6' => 'jce' 256 | } 257 | $security_dir = $package ? { 258 | 'jre' => "${java_home}/lib/security", 259 | default => "${java_home}/jre/lib/security" 260 | } 261 | if ( $use_cache ) { 262 | file { "${install_dir}/${jce_filename}": 263 | source => "${cache_source}${jce_filename}", 264 | require => File[$install_dir], 265 | } 266 | -> exec { 'get_jce_package': 267 | cwd => $install_dir, 268 | creates => "${install_dir}/jce_from_cache", 269 | command => 'touch jce_from_cache', 270 | } 271 | } else { 272 | archive { "${install_dir}/${jce_filename}": 273 | ensure => present, 274 | extract => true, 275 | source => $jdc_download_uri, 276 | proxy_server => $jdk_oracle::proxy_host, 277 | cookie => 'oraclelicense=accept-securebackup-cookie', 278 | extract_path => $security_dir, 279 | extract_command => "unzip -d ${security_dir} -o -j %s", 280 | creates => "${security_dir}/README.txt", 281 | cleanup => true, 282 | require => [Archive["${install_dir}/${installer_filename}"],File[$java_home]], 283 | user => 'root', 284 | group => 'root', 285 | } 286 | } 287 | } 288 | } 289 | } 290 | -------------------------------------------------------------------------------- /manifests/suse.pp: -------------------------------------------------------------------------------- 1 | # == Class: jdk_oracle::suse 2 | # 3 | # Creates links, directories and alternatives for Suse 4 | # 5 | # === Parameters 6 | # 7 | class jdk_oracle::suse { 8 | 9 | $java_home_loc = $jdk_oracle::java_home 10 | 11 | # Make the update-alternatives priority integer based on version, version_u, version_b 12 | $ua_priority = $jdk_oracle::version * 1000000 + $jdk_oracle::version_u * 1000 + $jdk_oracle::version_b 13 | 14 | # These need to be created, and the paths used later 15 | $libjvm_root = '/usr/lib64/jvm' 16 | $export_root = '/usr/lib64/jvm-exports' 17 | 18 | file { [ $libjvm_root, $export_root ] : 19 | ensure => directory, 20 | require => Exec['extract_jdk'], 21 | } 22 | 23 | # To put the update-alternatives links in the right place 24 | $java_home_basename = inline_template('<%= File.basename(@java_home_loc) %>') 25 | $export_dir = "${export_root}/${java_home_basename}" 26 | 27 | file { $export_dir: 28 | ensure => directory, 29 | path => $export_dir, 30 | require => File[$export_root], 31 | } 32 | 33 | # Oracle-specific symlinks are versioned like so 34 | $export_version = "1.${jdk_oracle::version}.0" 35 | 36 | # Do all of the symlinks to jvm-exports 37 | file { "${export_dir}/jaas-${export_version}_Orac.jar" : 38 | ensure => link, 39 | target => "${java_home_loc}/jre/lib/rt.jar", 40 | require => File[ $export_dir ], 41 | } 42 | -> file { "${export_dir}/jaas-${export_version}.jar" : 43 | ensure => link, 44 | target => "${export_dir}/jaas-${export_version}_Orac.jar", 45 | } 46 | -> file { "${export_dir}/jaas.jar" : 47 | ensure => link, 48 | target => "${export_dir}/jaas-${export_version}_Orac.jar", 49 | } 50 | -> file { "${export_dir}/jce-${export_version}_Orac.jar" : 51 | ensure => link, 52 | target => "${java_home_loc}/jre/lib/jce.jar", 53 | } 54 | -> file { "${export_dir}/jce-${export_version}.jar" : 55 | ensure => link, 56 | target => "${export_dir}/jce-${export_version}_Orac.jar", 57 | } 58 | -> file { "${export_dir}/jce.jar" : 59 | ensure => link, 60 | target => "${export_dir}/jce-${export_version}_Orac.jar", 61 | } 62 | -> file { "${export_dir}/jdbc-stdext-${export_version}_Orac.jar" : 63 | ensure => link, 64 | target => "${java_home_loc}/jre/lib/rt.jar", 65 | } 66 | -> file { "${export_dir}/jdbc-stdext-${export_version}.jar" : 67 | ensure => link, 68 | target => "${export_dir}/jdbc-stdext-${export_version}_Orac.jar", 69 | } 70 | -> file { "${export_dir}/jdbc-stdext-3.0.jar" : 71 | ensure => link, 72 | target => "${export_dir}/jdbc-stdext-${export_version}_Orac.jar", 73 | } 74 | -> file { "${export_dir}/jdbc-stdext.jar" : 75 | ensure => link, 76 | target => "${export_dir}/jdbc-stdext-${export_version}_Orac.jar", 77 | } 78 | -> file { "${export_dir}/jndi-${export_version}_Orac.jar" : 79 | ensure => link, 80 | target => "${java_home_loc}/jre/lib/rt.jar", 81 | } 82 | -> file { "${export_dir}/jndi-${export_version}.jar" : 83 | ensure => link, 84 | target => "${export_dir}/jndi-${export_version}_Orac.jar", 85 | } 86 | -> file { "${export_dir}/jndi.jar" : 87 | ensure => link, 88 | target => "${export_dir}/jndi-${export_version}_Orac.jar", 89 | } 90 | -> file { "${export_dir}/jndi-cos-${export_version}_Orac.jar" : 91 | ensure => link, 92 | target => "${java_home_loc}/jre/lib/rt.jar", 93 | } 94 | -> file { "${export_dir}/jndi-cos-${export_version}.jar" : 95 | ensure => link, 96 | target => "${export_dir}/jndi-cos-${export_version}_Orac.jar", 97 | } 98 | -> file { "${export_dir}/jndi-cos.jar" : 99 | ensure => link, 100 | target => "${export_dir}/jndi-cos-${export_version}_Orac.jar", 101 | } 102 | -> file { "${export_dir}/jndi-ldap-${export_version}_Orac.jar" : 103 | ensure => link, 104 | target => "${java_home_loc}/jre/lib/rt.jar", 105 | } 106 | -> file { "${export_dir}/jndi-ldap-${export_version}.jar" : 107 | ensure => link, 108 | target => "${export_dir}/jndi-ldap-${export_version}_Orac.jar", 109 | } 110 | -> file { "${export_dir}/jndi-ldap.jar" : 111 | ensure => link, 112 | target => "${export_dir}/jndi-ldap-${export_version}_Orac.jar", 113 | } 114 | -> file { "${export_dir}/jndi-rmi-${export_version}_Orac.jar" : 115 | ensure => link, 116 | target => "${java_home_loc}/jre/lib/rt.jar", 117 | } 118 | -> file { "${export_dir}/jndi-rmi-${export_version}.jar" : 119 | ensure => link, 120 | target => "${export_dir}/jndi-rmi-${export_version}_Orac.jar", 121 | } 122 | -> file { "${export_dir}/jndi-rmi.jar" : 123 | ensure => link, 124 | target => "${export_dir}/jndi-rmi-${export_version}_Orac.jar", 125 | } 126 | -> file { "${export_dir}/jsse-${export_version}_Orac.jar" : 127 | ensure => link, 128 | target => "${java_home_loc}/jre/lib/jsse.jar", 129 | } 130 | -> file { "${export_dir}/jsse-${export_version}.jar" : 131 | ensure => link, 132 | target => "${export_dir}/jsse-${export_version}_Orac.jar", 133 | } 134 | -> file { "${export_dir}/jsse.jar" : 135 | ensure => link, 136 | target => "${export_dir}/jsse-${export_version}_Orac.jar", 137 | } 138 | -> file { "${export_dir}/sasl-${export_version}_Orac.jar" : 139 | ensure => link, 140 | target => "${java_home_loc}/jre/lib/rt.jar", 141 | } 142 | -> file { "${export_dir}/sasl-${export_version}.jar" : 143 | ensure => link, 144 | target => "${export_dir}/sasl-${export_version}_Orac.jar", 145 | } 146 | -> file { "${export_dir}/sasl.jar" : 147 | ensure => link, 148 | target => "${export_dir}/sasl-${export_version}_Orac.jar", 149 | } 150 | 151 | 152 | $alt_java = "\ 153 | /usr/sbin/update-alternatives --install /usr/bin/java java ${java_home_loc}/bin/java ${ua_priority} \ 154 | --slave /usr/lib64/jvm/jre jre ${java_home_loc}/jre \ 155 | --slave /usr/lib64/jvm-exports/jre jre_exports /usr/lib64/jvm-exports/${java_home_basename} \ 156 | --slave /usr/bin/keytool keytool ${java_home_loc}/bin/keytool \ 157 | --slave /usr/bin/orbd orbd ${java_home_loc}/bin/orbd \ 158 | --slave /usr/bin/policytool policytool ${java_home_loc}/bin/policytool \ 159 | --slave /usr/bin/rmid rmid ${java_home_loc}/bin/rmid \ 160 | --slave /usr/bin/rmiregistry rmiregistry ${java_home_loc}/bin/rmiregistry \ 161 | --slave /usr/bin/servertool servertool ${java_home_loc}/bin/servertool \ 162 | --slave /usr/bin/tnameserv tnameserv ${java_home_loc}/bin/tnameserv \ 163 | --slave /usr/share/man/man1/java.1 java.1 ${java_home_loc}/man/man1/java.1 \ 164 | --slave /usr/share/man/man1/keytool.1 keytool.1 ${java_home_loc}/man/man1/keytool.1 \ 165 | --slave /usr/share/man/man1/orbd.1 orbd.1 ${java_home_loc}/man/man1/orbd.1 \ 166 | --slave /usr/share/man/man1/policytool.1 policytool.1 ${java_home_loc}/man/man1/policytool.1 \ 167 | --slave /usr/share/man/man1/rmid.1 rmid.1 ${java_home_loc}/man/man1/rmid.1 \ 168 | --slave /usr/share/man/man1/rmiregistry.1 rmiregistry.1 ${java_home_loc}/man/man1/rmiregistry.1 \ 169 | --slave /usr/share/man/man1/servertool.1 servertool.1 ${java_home_loc}/man/man1/servertool.1 \ 170 | --slave /usr/share/man/man1/tnameserv.1 tnameserv.1 ${java_home_loc}/man/man1/tnameserv.1 \ 171 | " 172 | 173 | $alt_javac = "\ 174 | /usr/sbin/update-alternatives --install /usr/bin/javac javac ${java_home_loc}/bin/javac ${ua_priority} \ 175 | --slave /usr/bin/appletviewer appletviewer ${java_home_loc}/bin/appletviewer \ 176 | --slave /usr/bin/apt apt ${java_home_loc}/bin/apt \ 177 | --slave /usr/bin/extcheck extcheck ${java_home_loc}/bin/extcheck \ 178 | --slave /usr/bin/jar jar ${java_home_loc}/bin/jar \ 179 | --slave /usr/bin/jarsigner jarsigner ${java_home_loc}/bin/jarsigner \ 180 | --slave /usr/lib64/jvm/java java_sdk ${java_home_loc} \ 181 | --slave /usr/lib64/jvm-exports/java java_sdk_exports /usr/lib64/jvm-exports/${java_home_basename} \ 182 | --slave /usr/bin/javadoc javadoc ${java_home_loc}/bin/javadoc \ 183 | --slave /usr/bin/javah javah ${java_home_loc}/bin/javah \ 184 | --slave /usr/bin/javap javap ${java_home_loc}/bin/javap \ 185 | --slave /usr/bin/jconsole jconsole ${java_home_loc}/bin/jconsole \ 186 | --slave /usr/bin/jdb jdb ${java_home_loc}/bin/jdb \ 187 | --slave /usr/bin/jhat jhat ${java_home_loc}/bin/jhat \ 188 | --slave /usr/bin/jinfo jinfo ${java_home_loc}/bin/jinfo \ 189 | --slave /usr/bin/jmap jmap ${java_home_loc}/bin/jmap \ 190 | --slave /usr/bin/jps jps ${java_home_loc}/bin/jps \ 191 | --slave /usr/bin/jrunscript jrunscript ${java_home_loc}/bin/jrunscript \ 192 | --slave /usr/bin/jsadebugd jsadebugd ${java_home_loc}/bin/jsadebugd \ 193 | --slave /usr/bin/jstack jstack ${java_home_loc}/bin/jstack \ 194 | --slave /usr/bin/jstat jstat ${java_home_loc}/bin/jstat \ 195 | --slave /usr/bin/jstatd jstatd ${java_home_loc}/bin/jstatd \ 196 | --slave /usr/bin/native2ascii native2ascii ${java_home_loc}/bin/native2ascii \ 197 | --slave /usr/bin/pack200 pack200 ${java_home_loc}/bin/pack200 \ 198 | --slave /usr/bin/rmic rmic ${java_home_loc}/bin/rmic \ 199 | --slave /usr/bin/schemagen schemagen ${java_home_loc}/bin/schemagen \ 200 | --slave /usr/bin/serialver serialver ${java_home_loc}/bin/serialver \ 201 | --slave /usr/bin/unpack200 unpack200 ${java_home_loc}/bin/unpack200 \ 202 | --slave /usr/bin/wsgen wsgen ${java_home_loc}/bin/wsgen \ 203 | --slave /usr/bin/wsimport wsimport ${java_home_loc}/bin/wsimport \ 204 | --slave /usr/bin/xjc xjc ${java_home_loc}/bin/xjc \ 205 | --slave /usr/share/man/man1/appletviewer.1 appletviewer.1 ${java_home_loc}/man/man1/appletviewer.1 \ 206 | --slave /usr/share/man/man1/apt.1 apt.1 ${java_home_loc}/man/man1/apt.1 \ 207 | --slave /usr/share/man/man1/extcheck.1 extcheck.1 ${java_home_loc}/man/man1/extcheck.1 \ 208 | --slave /usr/share/man/man1/jar.1 jar.1 ${java_home_loc}/man/man1/jar.1 \ 209 | --slave /usr/share/man/man1/jarsigner.1 jarsigner.1 ${java_home_loc}/man/man1/jarsigner.1 \ 210 | --slave /usr/share/man/man1/javac.1 javac.1 ${java_home_loc}/man/man1/javac.1 \ 211 | --slave /usr/share/man/man1/javadoc.1 javadoc.1 ${java_home_loc}/man/man1/javadoc.1 \ 212 | --slave /usr/share/man/man1/javah.1 javah.1 ${java_home_loc}/man/man1/javah.1 \ 213 | --slave /usr/share/man/man1/javap.1 javap.1 ${java_home_loc}/man/man1/javap.1 \ 214 | --slave /usr/share/man/man1/jcmd.1 jcmd.1 ${java_home_loc}/man/man1/jcmd.1 \ 215 | --slave /usr/share/man/man1/jconsole.1 jconsole.1 ${java_home_loc}/man/man1/jconsole.1 \ 216 | --slave /usr/share/man/man1/jdb.1 jdb.1 ${java_home_loc}/man/man1/jdb.1 \ 217 | --slave /usr/share/man/man1/jhat.1 jhat.1 ${java_home_loc}/man/man1/jhat.1 \ 218 | --slave /usr/share/man/man1/jinfo.1 jinfo.1 ${java_home_loc}/man/man1/jinfo.1 \ 219 | --slave /usr/share/man/man1/jmap.1 jmap.1 ${java_home_loc}/man/man1/jmap.1 \ 220 | --slave /usr/share/man/man1/jps.1 jps.1 ${java_home_loc}/man/man1/jps.1 \ 221 | --slave /usr/share/man/man1/jrunscript.1 jrunscript.1 ${java_home_loc}/man/man1/jrunscript.1 \ 222 | --slave /usr/share/man/man1/jsadebugd.1 jsadebugd.1 ${java_home_loc}/man/man1/jsadebugd.1 \ 223 | --slave /usr/share/man/man1/jstack.1 jstack.1 ${java_home_loc}/man/man1/jstack.1 \ 224 | --slave /usr/share/man/man1/jstat.1 jstat.1 ${java_home_loc}/man/man1/jstat.1 \ 225 | --slave /usr/share/man/man1/jstatd.1 jstatd.1 ${java_home_loc}/man/man1/jstatd.1 \ 226 | --slave /usr/share/man/man1/native2ascii.1 native2ascii.1 ${java_home_loc}/man/man1/native2ascii.1 \ 227 | --slave /usr/share/man/man1/pack200.1 pack200.1 ${java_home_loc}/man/man1/pack200.1 \ 228 | --slave /usr/share/man/man1/rmic.1 rmic.1 ${java_home_loc}/man/man1/rmic.1 \ 229 | --slave /usr/share/man/man1/schemagen.1 schemagen.1 ${java_home_loc}/man/man1/schemagen.1 \ 230 | --slave /usr/share/man/man1/serialver.1 serialver.1 ${java_home_loc}/man/man1/serialver.1 \ 231 | --slave /usr/share/man/man1/unpack200.1 unpack200.1 ${java_home_loc}/man/man1/unpack200.1 \ 232 | --slave /usr/share/man/man1/wsgen.1 wsgen.1 ${java_home_loc}/man/man1/wsgen.1 \ 233 | --slave /usr/share/man/man1/wsimport.1 wsimport.1 ${java_home_loc}/man/man1/wsimport.1 \ 234 | --slave /usr/share/man/man1/xjc.1 xjc.1 ${java_home_loc}/man/man1/xjc.1 \ 235 | " 236 | 237 | exec { 'update_alternatives_java' : 238 | command => $alt_java, 239 | require => [ File[$libjvm_root], Exec['extract_jdk'] ], 240 | unless => "test $(readlink /etc/alternatives/java) = '${java_home_loc}/bin/java'", 241 | } 242 | exec { 'update_alternatives_javac' : 243 | command => $alt_javac, 244 | require => [ File[$libjvm_root], Exec['extract_jdk'] ], 245 | unless => "test $(readlink /etc/alternatives/java) = '${java_home_loc}/bin/java'", 246 | } 247 | } 248 | --------------------------------------------------------------------------------