diff --git a/.travis.yml b/.travis.yml index 25e19ee..a7fdd7c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ --- script: "./script/cibuild" -gemfile: "this/does/not/exist" +gemfile: "Gemfile" rvm: - - "1.8.7" - - "1.9.3" + - "2.3.3" diff --git a/Gemfile b/Gemfile index 5263ca0..c360ac2 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,3 @@ source "https://rubygems.org" -gem "cardboard", "~> 2.1.0" +gem "cardboard23", "~> 3.0.0b" diff --git a/Gemfile.lock b/Gemfile.lock index 98b1f9a..37ea2fa 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,79 +2,112 @@ GEM remote: https://rubygems.org/ specs: CFPropertyList (2.2.8) - addressable (2.3.6) - ansi (1.4.3) - boxen (2.7.0) - ansi (~> 1.4) - hiera (~> 1.0) - highline (~> 1.6) - json_pure (>= 1.7.7, < 2.0) - librarian-puppet (~> 1.0.0) - octokit (~> 2.7, >= 2.7.1) - puppet (~> 3.7) - cardboard (2.1.0) - boxen (~> 2.1) - puppet-lint (~> 0.3) - puppetlabs_spec_helper (~> 0.4) - rspec-puppet (~> 1.0) - diff-lcs (1.2.5) - facter (2.3.0) - CFPropertyList (~> 2.2.6) - faraday (0.9.0) + addressable (2.3.8) + ansi (1.5.0) + boxen23 (4.0.0a) + ansi (~> 1.5) + hiera (~> 3.4) + highline (~> 1.7) + json_pure (>= 1.8.3, < 2.0) + octokit (~> 3.8, >= 3.8.0) + puppet (~> 4.10) + cardboard23 (3.0.0b) + boxen23 (= 4.0.0a) + librarian-puppet (~> 2.2) + librarianp (~> 0.6) + puppet-lint (~> 2.3) + puppetlabs_spec_helper (~> 2.4) + rspec-puppet (~> 2.6) + diff-lcs (1.3) + facter (2.5.7) + facter (2.5.7-universal-darwin) + CFPropertyList (~> 2.2) + faraday (0.9.2) multipart-post (>= 1.2, < 3) - hiera (1.3.4) - json_pure - highline (1.6.21) - json (1.8.1) - json_pure (1.8.1) - librarian (0.1.2) - highline + faraday_middleware (0.14.0) + faraday (>= 0.7.4, < 1.0) + fast_gettext (1.1.2) + gettext (3.2.9) + locale (>= 2.0.5) + text (>= 1.3.0) + gettext-setup (0.34) + fast_gettext (~> 1.1.0) + gettext (>= 3.0.2, < 3.3.0) + locale + hiera (3.6.0) + highline (1.7.10) + json_pure (1.8.6) + librarian-puppet (2.2.3) + librarianp (>= 0.6.3) + puppet_forge (~> 2.1) + rsync + librarianp (0.6.4) thor (~> 0.15) - librarian-puppet (1.0.9) - json - librarian (>= 0.1.2) - metaclass (0.0.4) - mocha (1.1.0) - metaclass (~> 0.0.1) - multipart-post (2.0.0) - octokit (2.7.2) - sawyer (~> 0.5.2) - puppet (3.7.3) - facter (> 1.6, < 3) - hiera (~> 1.0) - json_pure - puppet-lint (0.3.2) - puppet-syntax (1.3.0) - rake - puppetlabs_spec_helper (0.8.2) - mocha - puppet-lint - puppet-syntax + locale (2.1.3) + minitar (0.9) + mocha (1.11.2) + multipart-post (2.1.1) + octokit (3.8.0) + sawyer (~> 0.6.0, >= 0.5.3) + pathspec (0.2.1) + puppet (4.10.12) + facter (> 2.0, < 4) + gettext-setup (>= 0.10, < 1) + hiera (>= 2.0, < 4) + json_pure (~> 1.8) + locale (~> 2.1) + puppet (4.10.12-universal-darwin) + CFPropertyList (~> 2.2.6) + facter (> 2.0, < 4) + gettext-setup (>= 0.10, < 1) + hiera (>= 2.0, < 4) + json_pure (~> 1.8) + locale (~> 2.1) + puppet-lint (2.4.2) + puppet-syntax (2.6.0) rake - rspec - rspec-puppet - rake (10.4.2) - rspec (3.1.0) - rspec-core (~> 3.1.0) - rspec-expectations (~> 3.1.0) - rspec-mocks (~> 3.1.0) - rspec-core (3.1.7) - rspec-support (~> 3.1.0) - rspec-expectations (3.1.2) + puppet_forge (2.3.4) + faraday (>= 0.9.0, < 0.18.0, != 0.13.1) + faraday_middleware (>= 0.9.0, < 0.15.0) + gettext-setup (~> 0.11) + minitar + semantic_puppet (~> 1.0) + puppetlabs_spec_helper (2.14.1) + mocha (~> 1.0) + pathspec (~> 0.2.1) + puppet-lint (~> 2.0) + puppet-syntax (~> 2.0) + rspec-puppet (~> 2.0) + rake (13.0.1) + rspec (3.9.0) + rspec-core (~> 3.9.0) + rspec-expectations (~> 3.9.0) + rspec-mocks (~> 3.9.0) + rspec-core (3.9.2) + rspec-support (~> 3.9.3) + rspec-expectations (3.9.2) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.9.0) + rspec-mocks (3.9.1) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.1.0) - rspec-mocks (3.1.3) - rspec-support (~> 3.1.0) - rspec-puppet (1.0.1) + rspec-support (~> 3.9.0) + rspec-puppet (2.7.8) rspec - rspec-support (3.1.2) - sawyer (0.5.5) + rspec-support (3.9.3) + rsync (1.0.9) + sawyer (0.6.0) addressable (~> 2.3.5) faraday (~> 0.8, < 0.10) - thor (0.19.1) + semantic_puppet (1.0.2) + text (1.3.1) + thor (0.20.3) PLATFORMS ruby + universal-darwin-17 DEPENDENCIES - cardboard (~> 2.1.0) + cardboard23 (~> 3.0.0b) + +BUNDLED WITH + 2.1.4 diff --git a/README.md b/README.md index dd65c5d..d866a5a 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Build Status](https://travis-ci.org/boxen/puppet-java.png?branch=master)](https://travis-ci.org/boxen/puppet-java) -Installs Java 7 and unlimited key length security policy files.. +Installs Oracle Java 8. ## Usage @@ -14,18 +14,19 @@ include java ## Parameters -You can customise this module by configuring some optional class parameters. Usually you'd do this via Hiera, but you could also explicitly pass those parameters in puppet code like `class { 'java': update_version => '42', }`. +You can customise this module by configuring some optional class parameters. Usually you'd do this via Hiera, but you could also explicitly pass those parameters in puppet code like `class { 'java': update_version => '152', minor_Version => 'b16', hash_versoin => 'aa0333dd3019491ca4f6ddbe78cdb6d0' }`. -* `update_version`: The 'update' part of the JRE/JDK version to install. For example, if you specify `51`, the module would install java 7u51 -* `base_download_url`: A base path from which the JRE and JDK packages should be downloaded. For example, if you specify `https://myorg.example/dist/java`, this module would download the jre from `https://myorg.example/dist/java/jre-7u51-macosx-x64.dmg`. +* `update_version`: The 'update' part of the JDK version to install. For example, if you specify `152`, the module would install java 8u152 +* `minor_version`, `hash_version`: The 'minor' part of the JDK download URL. For example download URL is http://download.oracle.com/otn-pub/java/jdk/8u152-b16/aa0333dd3019491ca4f6ddbe78cdb6d0/jdk-8u152-macosx-x64.dmg, minor verson is 'b16'. All of these parameters have sensible defaults, and are provided if you need more control. Example hiera data in YAML: ```yaml -java::update_version: '51' -java::base_download_url: 'https://myorg.example/dist/java' +java::update_version: '152' +java::minor_version: 'b16' +java::hash_version: 'aa0333dd3019491ca4f6ddbe78cdb6d0' ``` ## Required Puppet Modules diff --git a/manifests/idrac7.pp b/manifests/idrac7.pp deleted file mode 100644 index 78b99bd..0000000 --- a/manifests/idrac7.pp +++ /dev/null @@ -1,26 +0,0 @@ -# Public: Dell DRAC and Java 7 Certificate Fix -# http://people.binf.ku.dk/~hanne/b2evolution/blogs/index.php/2012/08/09/dell-idrac-7-will-not -# -# Examples -# -# include java::idrac7 -class java::idrac7 { - include java - - file { [ - "/Users/${::boxen_user}/.java", - "/Users/${::boxen_user}/.java/deployment", - "/Users/${::boxen_user}/.java/deployment/security" - ]: - ensure => directory, - mode => '0750'; - "/Users/${::boxen_user}/.java/deployment/security/trusted.certs": - ensure => file, - mode => '0640', - source => 'puppet:///modules/java/trusted.certs'; - "/Users/${::boxen_user}/.java/deployment/security/trusted.jssecerts": - ensure => file, - mode => '0640', - source => 'puppet:///modules/java/trusted.jssecerts'; - } -} diff --git a/manifests/init.pp b/manifests/init.pp index 2ed7823..6d72b8b 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,74 +1,36 @@ -# Public: installs java jre-7u51 and JCE unlimited key size policy files +# Public: installs java jdk and JCE unlimited key size policy files # # Examples # # include java + class java ( - $update_version = '71', - $base_download_url = 'https://s3.amazonaws.com/boxen-downloads/java' + $major_version = '14.0.1', + $minor_version = '7', + $hash_version = '664493ef4a6946b186ff29eb326336a2' ) { include boxen::config - $jre_url = "${base_download_url}/jre-7u${update_version}-macosx-x64.dmg" - $jdk_url = "${base_download_url}/jdk-7u${update_version}-macosx-x64.dmg" $wrapper = "${boxen::config::bindir}/java" - $jdk_dir = "/Library/Java/JavaVirtualMachines/jdk1.7.0_${update_version}.jdk" - $sec_dir = "${jdk_dir}/Contents/Home/jre/lib/security" - - if ((versioncmp($::macosx_productversion_major, '10.10') >= 0) and - versioncmp($update_version, '71') < 0) - { - fail('Yosemite Requires Java 7 with a patch level >= 71 (Bug JDK-8027686)') - } + $jdk_download_url = "https://download.oracle.com/otn-pub/java/jdk/${major_version}+${minor_version}/${hash_version}" + $jdk_package = "jdk-${major_version}_osx-x64_bin.dmg" + $jdk_dir = '/Library/Java/JavaVirtualMachines' file { $wrapper: - source => 'puppet:///modules/java/java.sh', - mode => '0755' + source => 'puppet:///modules/java/java.sh', + mode => '0755', } - if (versioncmp($::java_jre_version, '1.8.0') < 0) { - package { - "jre-7u${update_version}.dmg": - ensure => present, - alias => 'java-jre', - provider => pkgdmg, - source => $jre_url ; - } + exec { "download ${jdk_package}": + command => "wget --quiet --no-check-certificate --no-cookies --header 'Cookie: oraclelicense=accept-securebackup-cookie' ${jdk_download_url}/${jdk_package} -P ${jdk_dir}", + user => root, + creates => "${jdk_dir}/${jdk_package}", + require => Package['wget'], } - if (versioncmp($::java_version, '1.8.0') < 0) { - package { - "jdk-7u${update_version}.dmg": - ensure => present, - alias => 'java', - provider => pkgdmg, - source => $jdk_url ; - } - - # Allow 'large' keys locally. - # http://www.ngs.ac.uk/tools/jcepolicyfiles - file { $sec_dir: - ensure => 'directory', - owner => 'root', - group => 'wheel', - mode => '0775', - require => Package['java'] - } - - file { "${sec_dir}/local_policy.jar": - source => 'puppet:///modules/java/local_policy.jar', - owner => 'root', - group => 'wheel', - mode => '0664', - require => File[$sec_dir] - } - - file { "${sec_dir}/US_export_policy.jar": - source => 'puppet:///modules/java/US_export_policy.jar', - owner => 'root', - group => 'wheel', - mode => '0664', - require => File[$sec_dir] - } + package { $jdk_package: + provider => pkgdmg, + source => "${jdk_dir}/${jdk_package}", + require => Exec["download ${jdk_package}"], } } diff --git a/script/cardboard-exec b/script/cardboard-exec index 664c5d2..ba36ab1 100755 --- a/script/cardboard-exec +++ b/script/cardboard-exec @@ -9,10 +9,14 @@ BUNDLE=.bundle BIN=$BUNDLE/binstubs SCRIPT=$(basename "$0") -BUNDLE_ARGS="--binstubs $BIN --path $BUNDLE --quiet" +BUNDLE_ARGS="--quiet" [ "cibuild" = "$SCRIPT" ] && BUNDLE_ARGS="$BUNDLE_ARGS --no-quiet" rm -rf {$BIN,$BUNDLE/config} +bundle config path $BUNDLE +set +e +bundle binstubs --path=$BIN +set -e bundle install $BUNDLE_ARGS bundle exec cardboard bootstrap diff --git a/spec/classes/java_idrac7_spec.rb b/spec/classes/java_idrac7_spec.rb deleted file mode 100644 index 7bbdd15..0000000 --- a/spec/classes/java_idrac7_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'spec_helper' - -describe "java::idrac7" do - let(:facts) { default_test_facts } - - it do - should contain_class('java') - - ['.java', '.java/deployment', '.java/deployment/security'].each do |dir| - should contain_file("/Users/testuser/#{dir}").with({ - :ensure => 'directory', - :mode => '0750' - }) - end - - should contain_file("/Users/testuser/.java/deployment/security/trusted.certs").with({ - :ensure => 'file', - :mode => '0640', - :source => 'puppet:///modules/java/trusted.certs' - }) - - should contain_file("/Users/testuser/.java/deployment/security/trusted.jssecerts").with({ - :ensure => 'file', - :mode => '0640', - :source => 'puppet:///modules/java/trusted.jssecerts' - }) - end -end diff --git a/spec/classes/java_spec.rb b/spec/classes/java_spec.rb index bb7a317..122afa0 100644 --- a/spec/classes/java_spec.rb +++ b/spec/classes/java_spec.rb @@ -4,45 +4,31 @@ let(:facts) { default_test_facts } let(:params) { { - :update_version => '42', - :base_download_url => 'https://downloads.test/java' + :major_version => '14.0.1', + :minor_version => '7', + :hash_version => '664493ef4a6946b186ff29eb326336a2' } } it do should contain_class('boxen::config') - should contain_package('jre-7u42.dmg').with({ - :ensure => 'present', - :alias => 'java-jre', - :provider => 'pkgdmg', - :source => 'https://downloads.test/java/jre-7u42-macosx-x64.dmg' + should contain_file('/test/boxen/bin/java').with({ + :source => 'puppet:///modules/java/java.sh', + :mode => '0755' }) - should contain_package('jdk-7u42.dmg').with({ - :ensure => 'present', - :alias => 'java', - :provider => 'pkgdmg', - :source => 'https://downloads.test/java/jdk-7u42-macosx-x64.dmg' + should contain_exec("download jdk-#{params[:major_version]}_osx-x64_bin.dmg").with({ + :command => "wget --quiet --no-check-certificate --no-cookies --header \'Cookie: oraclelicense=accept-securebackup-cookie\' https://download.oracle.com/otn-pub/java/jdk/#{params[:major_version]}+#{params[:minor_version]}/#{params[:hash_version]}/jdk-#{params[:major_version]}_osx-x64_bin.dmg -P /Library/Java/JavaVirtualMachines", + :user => 'root', + :creates => "/Library/Java/JavaVirtualMachines/jdk-#{params[:major_version]}_osx-x64_bin.dmg", + :require => 'Package[wget]', }) - should contain_file('/test/boxen/bin/java').with({ - :source => 'puppet:///modules/java/java.sh', - :mode => '0755' + should contain_package("jdk-#{params[:major_version]}_osx-x64_bin.dmg").with({ + :provider => 'pkgdmg', + :source => "/Library/Java/JavaVirtualMachines/jdk-#{params[:major_version]}_osx-x64_bin.dmg", + :require => "Exec[download jdk-#{params[:major_version]}_osx-x64_bin.dmg]", }) end - - context 'fails when java version has Yosemite relevant bug' do - let(:facts) { default_test_facts.merge({ :macosx_productversion_major => '10.10' }) } - let(:params) { - { - :update_version => '51', - } - } - it do - expect { - should contain_class('java') - }.to raise_error(/Yosemite Requires Java 7 with a patch level >= 71 \(Bug JDK\-8027686\)/) - end - end end diff --git a/spec/fixtures/.gitignore b/spec/fixtures/.gitignore new file mode 100644 index 0000000..5aa5608 --- /dev/null +++ b/spec/fixtures/.gitignore @@ -0,0 +1,2 @@ +.tmp/ +modules/ diff --git a/spec/fixtures/Puppetfile b/spec/fixtures/Puppetfile index a649dda..284f6e4 100644 --- a/spec/fixtures/Puppetfile +++ b/spec/fixtures/Puppetfile @@ -1 +1,2 @@ -mod 'boxen', '3.0.2', :github_tarball => 'boxen/puppet-boxen' +mod 'boxen', '3.13.0c', :github_tarball => 'n0ts/puppet-boxen' +mod 'stdlib', '4.17.1', :github_tarball => 'puppetlabs/puppetlabs-stdlib' diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d40a1c2..09c50ae 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -9,7 +9,10 @@ def default_test_facts { - :boxen_home => "/test/boxen", - :boxen_user => "testuser" + :boxen_home => '/test/boxen', + :boxen_user => 'testuser', + :boxen_repodir => File.join(File.dirname(__FILE__), 'fixtures'), + :boxen_repo_url_template => "https://github.com/%s", + :boxen_srcdir => '~/src', } end