Skip to content
This repository was archived by the owner on Dec 2, 2020. It is now read-only.

Commit 3f9ba39

Browse files
committed
Merge pull request #32 from boxen/flexible-versions
Flexible versions
2 parents 724e0b6 + 6a6e6e3 commit 3f9ba39

File tree

3 files changed

+38
-11
lines changed

3 files changed

+38
-11
lines changed

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,32 @@
22

33
[![Build Status](https://travis-ci.org/boxen/puppet-java.png?branch=master)](https://travis-ci.org/boxen/puppet-java)
44

5-
Installs Java 7u51 and unlimited key length security policy files..
5+
Installs Java 7 and unlimited key length security policy files..
66

77

88
## Usage
99

1010
```puppet
11+
# Install the default version of both the JDK and JRE
1112
include java
1213
```
1314

15+
## Parameters
16+
17+
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', }`.
18+
19+
* `update_version`: The 'update' part of the JRE/JDK version to install. For example, if you specify `51`, the module would install java 7u51
20+
* `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`.
21+
22+
All of these parameters have sensible defaults, and are provided if you need more control.
23+
24+
Example hiera data in YAML:
25+
26+
```yaml
27+
java::update_version: '51'
28+
java::base_download_url: 'https://myorg.example/dist/java'
29+
```
30+
1431
## Required Puppet Modules
1532
1633
* `boxen`

manifests/init.pp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,25 @@
33
# Examples
44
#
55
# include java
6-
class java {
6+
class java (
7+
$update_version = '51',
8+
$base_download_url = 'https://s3.amazonaws.com/boxen-downloads/java'
9+
) {
710
include boxen::config
811

9-
$jre_url = 'https://s3.amazonaws.com/boxen-downloads/java/jre-7u51-macosx-x64.dmg'
10-
$jdk_url = 'https://s3.amazonaws.com/boxen-downloads/java/jdk-7u51-macosx-x64.dmg'
12+
$jre_url = "${base_download_url}/jre-7u${update_version}-macosx-x64.dmg"
13+
$jdk_url = "${base_download_url}/jdk-7u${update_version}-macosx-x64.dmg"
1114
$wrapper = "${boxen::config::bindir}/java"
12-
$sec_dir = '/Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home/jre/lib/security'
15+
$jdk_dir = "/Library/Java/JavaVirtualMachines/jdk1.7.0_${update_version}.jdk"
16+
$sec_dir = "${jdk_dir}/Contents/Home/jre/lib/security"
1317

1418
package {
15-
'jre-7u51.dmg':
19+
"jre-7u${update_version}.dmg":
1620
ensure => present,
1721
alias => 'java-jre',
1822
provider => pkgdmg,
1923
source => $jre_url ;
20-
'jdk-7u51.dmg':
24+
"jdk-7u${update_version}.dmg":
2125
ensure => present,
2226
alias => 'java',
2327
provider => pkgdmg,

spec/classes/java_spec.rb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,28 @@
22

33
describe "java" do
44
let(:facts) { default_test_facts }
5+
let(:params) {
6+
{
7+
:update_version => '42',
8+
:base_download_url => 'https://downloads.test/java'
9+
}
10+
}
511

612
it do
713
should include_class('boxen::config')
814

9-
should contain_package('jre-7u51.dmg').with({
15+
should contain_package('jre-7u42.dmg').with({
1016
:ensure => 'present',
1117
:alias => 'java-jre',
1218
:provider => 'pkgdmg',
13-
:source => 'https://s3.amazonaws.com/boxen-downloads/java/jre-7u51-macosx-x64.dmg'
19+
:source => 'https://downloads.test/java/jre-7u42-macosx-x64.dmg'
1420
})
1521

16-
should contain_package('jdk-7u51.dmg').with({
22+
should contain_package('jdk-7u42.dmg').with({
1723
:ensure => 'present',
1824
:alias => 'java',
1925
:provider => 'pkgdmg',
20-
:source => 'https://s3.amazonaws.com/boxen-downloads/java/jdk-7u51-macosx-x64.dmg'
26+
:source => 'https://downloads.test/java/jdk-7u42-macosx-x64.dmg'
2127
})
2228

2329
should contain_file('/test/boxen/bin/java').with({

0 commit comments

Comments
 (0)