From 001f0e85cd90e630a4d37c5ade92c269cb54d4d2 Mon Sep 17 00:00:00 2001 From: David Goodlad Date: Tue, 18 Mar 2014 13:33:59 +1300 Subject: [PATCH 1/3] Make the update version and download url params This way, if people roll want to override which version their Boxen installs, they can do so via hiera or explicit class parameters --- manifests/init.pp | 16 ++++++++++------ spec/classes/java_spec.rb | 14 ++++++++++---- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 23604f4..e85d2d1 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -3,21 +3,25 @@ # Examples # # include java -class java { +class java ( + $update_version = '51', + $base_download_url = 'https://s3.amazonaws.com/boxen-downloads/java' +) { include boxen::config - $jre_url = 'https://s3.amazonaws.com/boxen-downloads/java/jre-7u51-macosx-x64.dmg' - $jdk_url = 'https://s3.amazonaws.com/boxen-downloads/java/jdk-7u51-macosx-x64.dmg' + $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" - $sec_dir = '/Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home/jre/lib/security' + $jdk_dir = "/Library/Java/JavaVirtualMachines/jdk1.7.0_${update_version}.jdk" + $sec_dir = "${jdk_dir}/Contents/Home/jre/lib/security" package { - 'jre-7u51.dmg': + "jre-7u${update_version}.dmg": ensure => present, alias => 'java-jre', provider => pkgdmg, source => $jre_url ; - 'jdk-7u51.dmg': + "jdk-7u${update_version}.dmg": ensure => present, alias => 'java', provider => pkgdmg, diff --git a/spec/classes/java_spec.rb b/spec/classes/java_spec.rb index 86f4e76..2a4e936 100644 --- a/spec/classes/java_spec.rb +++ b/spec/classes/java_spec.rb @@ -2,22 +2,28 @@ describe "java" do let(:facts) { default_test_facts } + let(:params) { + { + update_version: '42', + base_download_url: 'https://downloads.test/java' + } + } it do should include_class('boxen::config') - should contain_package('jre-7u51.dmg').with({ + should contain_package('jre-7u42.dmg').with({ :ensure => 'present', :alias => 'java-jre', :provider => 'pkgdmg', - :source => 'https://s3.amazonaws.com/boxen-downloads/java/jre-7u51-macosx-x64.dmg' + :source => 'https://downloads.test/java/jre-7u42-macosx-x64.dmg' }) - should contain_package('jdk-7u51.dmg').with({ + should contain_package('jdk-7u42.dmg').with({ :ensure => 'present', :alias => 'java', :provider => 'pkgdmg', - :source => 'https://s3.amazonaws.com/boxen-downloads/java/jdk-7u51-macosx-x64.dmg' + :source => 'https://downloads.test/java/jdk-7u42-macosx-x64.dmg' }) should contain_file('/test/boxen/bin/java').with({ From 2c290ba3b9dc79bd5a7d89c389301b3ffdc07124 Mon Sep 17 00:00:00 2001 From: David Goodlad Date: Tue, 18 Mar 2014 13:44:30 +1300 Subject: [PATCH 2/3] Document the two new parameters --- README.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3dfaa9a..fd3692f 100644 --- a/README.md +++ b/README.md @@ -2,15 +2,32 @@ [![Build Status](https://travis-ci.org/boxen/puppet-java.png?branch=master)](https://travis-ci.org/boxen/puppet-java) -Installs Java 7u51 and unlimited key length security policy files.. +Installs Java 7 and unlimited key length security policy files.. ## Usage ```puppet +# Install the default version of both the JDK and JRE 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', }`. + +* `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`. + +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' +``` + ## Required Puppet Modules * `boxen` From 6a6e6e3aee59a5ffaa42a6ef6f6e9b500d258f84 Mon Sep 17 00:00:00 2001 From: David Goodlad Date: Wed, 19 Mar 2014 08:57:04 +1300 Subject: [PATCH 3/3] Drop Ruby 1.9 hash syntax --- spec/classes/java_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/classes/java_spec.rb b/spec/classes/java_spec.rb index 2a4e936..454cb91 100644 --- a/spec/classes/java_spec.rb +++ b/spec/classes/java_spec.rb @@ -4,8 +4,8 @@ let(:facts) { default_test_facts } let(:params) { { - update_version: '42', - base_download_url: 'https://downloads.test/java' + :update_version => '42', + :base_download_url => 'https://downloads.test/java' } }