Skip to content
This repository was archived by the owner on Dec 21, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ fixtures:
repositories:
windows_env: "git://github.com/badgerious/puppet-windows-env.git"
powershell: "git://github.com/puppetlabs/puppetlabs-powershell.git"
pget: "git://github.com/cyberious/puppet-pget.git"
download_file: "git@github.com:voxpupuli/puppet-download_file.git"
stdlib: "git://github.com/puppetlabs/puppetlabs-stdlib.git"
module_data: "git://github.com/ripienaar/puppet-module-data.git"
symlinks:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,5 @@ pip-log.txt

#Mr Developer
.mr.developer.cfg

*.lock
22 changes: 7 additions & 15 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,27 @@ This module can be used to install one or multiple JDK versions from Oracle

### Beginning with windows_java

####Install Oracle JDK Version 8u45
####Install Oracle JDK Version 8u45 by default
~~~puppet
include 'windows_java'
include '::windows_java'
~~~

This will install Oracle JDK version 8 update 45
This will install Oracle JDK version 8 update 45 by default

## Usage

####Install JDK 7u51 and not as default
~~~puppet
windows_java::jdk{'7u51':
class { '::windows_java':
version => '7u51',
default => false,
}
~~~

####Install JDK 7u51 non default location
~~~puppet
windows_java::jdk{'7u51':
class { '::windows_java':
version => '7u51',
install_path => 'G:\java\jdk7u51',
default => false,
}
Expand All @@ -60,15 +62,6 @@ windows_java::jdk{'7u51':

#### `windows_java`

* `ensure`: *Optional.* Whether to install or remove the version
* `version`: *Optional.* What version of the jdk to install. Defaults to '8u45'
* `arch`: *Optional.* What architecture you want to install, Valid options are 'x64','i586'. Default is: `$::architecture`
* `default`: *Optional.* Whether to update and set the JAVA_HOME and include in PATH environment variables

### Types

#### `windows_java::jdk`

* `ensure`: *Optional.* Whether to install or remove the version
* `version`: *Optional.* What version of the jdk to install. Defaults to '8u45'
* `arch`: *Optional.* What architecture you want to install, Valid options are 'x64','i586'. Default is: `$::architecture`
Expand All @@ -79,4 +72,3 @@ windows_java::jdk{'7u51':
* `install_path`: *Optional.* The location to install JDK to.
* `source`: *Optional.* Alternate source to download from, can be puppet:// http(s):// url
* `temp_target`: *Optional.* Temp target for downloading the JDK installer to, defaults to ENV['TEMP']

26 changes: 0 additions & 26 deletions manifests/download.pp

This file was deleted.

30 changes: 21 additions & 9 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,27 @@
# Copyright 2013 Your name here, unless otherwise noted.
#
class windows_java (
$ensure = 'present',
$version = '8u45',
$arch = $::architecture,
$default = true,
$ensure = 'present',
$version = '8u45',
$arch = $::architecture,
$build_number_hash = undef,
$cookie_string = undef,
$default = true,
$install_name = undef,
$install_path = undef,
$source = undef,
$temp_target = $::windows_java_temp,
) {
windows_java::jdk{ $name:
ensure => $ensure,
version => $version,
default => $default,
arch => $arch,
windows_java::jdk{ $version:
ensure => $ensure,
version => $version,
arch => $arch,
build_number_hash => $build_number_hash,
cookie_string => $cookie_string,
default => $default,
install_name => $install_name,
install_path => $install_path,
source => $source,
temp_target => $::windows_java_temp,
}
}
6 changes: 3 additions & 3 deletions manifests/install.pp
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
define windows_java::install (
$install_path,
$source,
$ensure = 'present',
$ensure = 'present',
$package_name = $name,
){
$_options = ['/s',{ 'INSTALLDIR' => $install_path }]
package{ $package_name:
ensure => $ensure,
provider => windows,
source => $source,
install_options => $_options
install_options => $_options,
}
}
}
56 changes: 29 additions & 27 deletions manifests/jdk.pp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#
# Copyright 2013 Your name here, unless otherwise noted.
#
define windows_java::jdk (
define windows_java::jdk (
$ensure = 'present',
$version = $name,
$arch = $::architecture,
Expand All @@ -53,8 +53,11 @@
$install_name = undef,
$install_path = undef,
$source = undef,
$temp_target = $::windows_java_temp,) {
include windows_java::params
$temp_target = $::windows_java_temp,
) {

validate_legacy(Boolean, 'validate_bool', $default)
include ::windows_java::params

$_splitversion = split($version,'[uU]')
$_major = $_splitversion[0]
Expand All @@ -73,18 +76,18 @@
}

if $install_name == undef {
$_installBase = "${::windows_java::params::jdk_base_install_name} ${_major}"
$_installUpdate = $_update ?{
$_install_base = "${::windows_java::params::jdk_base_install_name} ${_major}"
$_install_update = $_update ?{
/\d+/ => " Update ${_update}",
default => '',
}
$_installArch = $_arch_version ? {
$_install_arch = $_arch_version ? {
'x64' => ' (64-bit)',
default => '',
}
$_installName = "${_installBase}${_installUpdate}${_installArch}"
$_install_name = "${_install_base}${_install_update}${_install_arch}"
} else {
$_installName = $install_name
$_install_name = $install_name
}

if has_key($_build_hash, $version) {
Expand All @@ -105,40 +108,39 @@
$_remote_source = $source
$_filename = filename($_remote_source)
}
##
# Install Paths
#
##

if $::architecture == 'x86_64' and $_arch_version == 'i586'{
$_base_install_path = 'C:\Program Files (x86)\Java'
} else{
$_base_install_path = 'C:\Program Files\Java'
}
$_installPath = $install_path ? {
$_install_path = $install_path ? {
undef => "${_base_install_path}\\jdk1.${_major}.0_${_update}",
default => $install_path,
}

$_tempLocation = "${temp_target}\\${_filename}"
$_temp_location = "${temp_target}\\${_filename}"

windows_java::download { "Download-${_filename}":
source => $_remote_source,
filename => $_filename,
temp_target => $temp_target,
}->
windows_java::install{ $_installName:
download_file { "download-${_filename}":
url => $_remote_source,
destination_directory => $temp_target,
destination_file => $_filename,
cookies => [$::windows_java::params::cookie_string],
}
-> windows_java::install{ $_install_name:
ensure => $ensure,
source => $_tempLocation,
install_path => $_installPath,
source => $_temp_location,
install_path => $_install_path,
}
validate_bool($default)

if($default == true){
class{ 'windows_java::java_home':
install_path => $_installPath,
require => Windows_java::Install[$_installName] }
class{ '::windows_java::java_home':
install_path => $_install_path,
require => Windows_java::Install[$_install_name],
}
}
} else{
package{ $_installName:
package{ $_install_name:
ensure => $ensure,
provider => windows,
}
Expand Down
9 changes: 4 additions & 5 deletions manifests/params.pp
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
class windows_java::params {
$jdk_base_install_name = 'Java SE Development Kit'
$cookie_string = 'oraclelicense=accept-securebackup-cookie;gpw_e24=http://edelivery.oracle.com'
$root_url = 'http://download.oracle.com/otn-pub/java/jdk'

$build_numbers_hash = {
$cookie_string = 'oraclelicense=accept-securebackup-cookie;gpw_e24=http://edelivery.oracle.com'
$root_url = 'http://download.oracle.com/otn-pub/java/jdk'
$build_numbers_hash = {
'8u45' => 'b15',
'8u40' => 'b26',
'8u31' => 'b13',
Expand All @@ -22,4 +21,4 @@
'7u45' => 'b18',
'7u25' => 'b17',
}
}
}
8 changes: 4 additions & 4 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@
],
"dependencies": [
{
"name": "badgerious/windows_env",
"version_requirement": ">= 2.0.2"
"name": "puppet/windows_env",
"version_requirement": ">= 2.3.0"
},
{
"name": "cyberious/pget",
"version_requirement": ">= 1.0.0 < 2.0.0"
"name": "puppet/download_file",
"version_requirement": ">= 2.0.0 < 4.0.0"
},
{
"name": "puppetlabs/stdlib",
Expand Down
46 changes: 31 additions & 15 deletions spec/classes/windows_java_spec.rb
Original file line number Diff line number Diff line change
@@ -1,26 +1,42 @@
require 'spec_helper'
require 'rspec-puppet'

provider_class = Puppet::Type.type(:package).provider(:windows)

describe 'windows_java' do
before :each do
Puppet::Type.type(:package).stubs(:defaultprovider).returns(provider_class)
end
let(:title) { 'install jdk' }
let(:facts) { {:operatingsystem => 'windows', :architecture => 'x64', :windows_java_temp => 'C:\temp'} }
let(:params) { {:version => '8u45'} }
it {
should contain_windows_java__download('Download-jdk-8u45-windows-x64.exe').with(
{
'source' => 'http://download.oracle.com/otn-pub/java/jdk/8u45-b15/jdk-8u45-windows-x64.exe',
'filename' => 'jdk-8u45-windows-x64.exe',
'temp_target' => 'C:\temp'
})
let(:params) {
{
'ensure' => 'present',
'version' => '8u45',
'build_number_hash' => { '8u45' => 'b15' },
'default' => true,
'source' => 'http://download.oracle.com/otn-pub/java/jdk/8u45-b15/jdk-8u45-windows-x64.exe'
}
}
it {
should contain_package(
'Java SE Development Kit 8 Update 45 (64-bit)').with(
{
'ensure' => 'present'
})
is_expected.to contain_windows_java__jdk('8u45').with(
{
'ensure' => 'present',
'version' => '8u45',
'arch' => 'x64',
'build_number_hash' => { '8u45' => 'b15' },
'default' => true,
'source' => 'http://download.oracle.com/otn-pub/java/jdk/8u45-b15/jdk-8u45-windows-x64.exe',
'temp_target' => 'C:\temp'
}
)
}
it {
should contain_windows_env('JAVA_HOME').with_value('C:\Program Files\Java\jdk1.8.0_45')
is_expected.to contain_package('Java SE Development Kit 8 Update 45 (64-bit)').with(
{
'ensure' => 'present'
}
)
}
end
it { should contain_windows_env('JAVA_HOME').with_value('C:\Program Files\Java\jdk1.8.0_45') }
end
Loading