Skip to content
This repository has been archived by the owner on Jun 21, 2018. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
antoineco committed Jul 20, 2014
0 parents commit 4d35821
Show file tree
Hide file tree
Showing 5 changed files with 237 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
###1.0.0

First forge release
13 changes: 13 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright 2014 Antoine Cotten

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
12 changes: 12 additions & 0 deletions Modulefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name 'aco-oracle_java'
version '1.0.0'
source 'git://github.com/tOnI0/aco-oracle_java.git'
author 'Antoine Cotten'
license 'Apache License, Version 2.0'
summary 'Puppet module to install Oracle Java on RPM-based Linux systems'
description 'This module installs Oracle JRE or JDK from official RPM packages'
project_page 'https://github.com/tOnI0/aco-oracle_java'

## Add dependencies, if any:
# dependency 'username/name', '>= 1.2.0'
dependency 'puppetlabs/stdlib', '>=3.2.0'
92 changes: 92 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#oracle_java

####Table of Contents

1. [Overview](#overview)
2. [Module Description](#module-description)
3. [Setup](#setup)
4. [Usage](#usage)
5. [Limitations](#limitations)
6. [Credits](#credits)
7. [To Do](#to-do)

##Overview

The oracle_java module allows you to install the Oracle JRE or JDK of your choice from the official RPM archives provided by Oracle. It is especially intended for systems which do not need to have several Java versions installed in parallel.

##Module description

Oracle provides a RPM version of both its JRE and JDK for every Java release. These packages are available from the [Oracle Java Archive](http://www.oracle.com/technetwork/java/archive-139210.html). This module simply downloads the desired Java version and installs it on the target system.

##Setup

oracle_java will affect the following parts of your system:

* jre/jdk package

Including the main class is enough to install the latest version of the Oracle JRE.

```puppet
include ::oracle_java
```

####A couple of examples

Install the latest release of the Java 7 SE JRE

```puppet
class { '::oracle_java':
version => 7
}
```

Install the latest available JDK

```puppet
class { '::oracle_java':
type => 'jdk'
}
```

Install a specific version of the JDK

```puppet
class { '::oracle_java':
version => '7u45',
type => 'jdk'
}
```

##Usage

####Class: `oracle_java`

Primary class and entry point of the module.

**Parameters within `oracle_java`:**

#####`version`

Java version to install, formated as 'major_version'u'minor_version' or simply 'major_version' for the latest available release in the selected Java SE series. Defaults to '8'

Note: a minor version of '0' (for example '8u0') matches the initial release of the selected Java SE series.

#####`type`

What envionment type to install. Valid values are 'jre' and 'jdk'. Defaults to 'jre'

##Limitations

* 2 different versions of Oracle Java can not cohabit on the same system when installed from RPM. Each new version will override the previous one.
* Works only on [RPM-based distributions](http://en.wikipedia.org/wiki/List_of_Linux_distributions#RPM-based)

##Credits

This module relies almost entirely on all the nice information found on [Ivan Dyedov's Blog](https://ivan-site.com/2012/05/download-oracle-java-jre-jdk-using-a-script/)

##To DO

* Allow the manipulation of Java related environment variables
* Propose an alternative based on tar.gz archives, also available from Oracle's archives

Features request and contributions are always welcome!
117 changes: 117 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# === Class: oracle_java
#
# This module installs Oracle Java from official RPM packages
#
# == Parameters
#
# $version:
# Java SE version to install (valid format: 'major'u'minor' or just 'major')
# $type:
# envionment type to install (valid: 'jre'|'jdk')
#
# === Actions
#
# - Install Oracle jre/jdk
#
# === Requires
#
# - puppetlabs/stdlib module
#
# === Sample Usage:
#
# class { '::oracle_java':
# version => '8u5',
# type => 'jdk'
# }
#
class oracle_java ($version = '8', $type = 'jre') {
# translate system architecture to expected value
case $::architecture {
'x86_64' : { $arch = 'x64' }
'x86' : { $arch = 'i586' }
default : { fail("Unsupported architecture ${arch}") }
}

# set to latest release if no minor version was provided
if $version == '8' {
$version_real = '8u5'
} elsif $version == '7' {
$version_real = '7u60'
} else {
$version_real = $version
}

# get major/minor version numbers
$array_version = split($version_real, 'u')
$maj_version = $array_version[0]
$min_version = $array_version[1]

# associate build number to release version
case $maj_version {
8 : {
case $min_version {
'5' : { $build = '-b13' }
'0' : { $build = '-b132' }
default : { fail("Unexisting update number ${min_version}") }
}
}
7 : {
case $min_version {
'60' : { $build = '-b19' }
'55' : { $build = '-b13' }
'51' : { $build = '-b13' }
'45' : { $build = '-b18' }
'40' : { $build = '-b43' }
'25' : { $build = '-b15' }
'21' : { $build = '-b11' }
'17' : { $build = '-b02' }
'15' : { $build = '-b03' }
'13' : { $build = '-b20' }
'11' : { $build = '-b21' }
'10' : { $build = '-b18' }
'9' : { $build = '-b05' }
'7' : { $build = '-b10' }
'6' : { $build = '-b24' }
'5' : { $build = '-b06' }
'4' : { $build = '-b20' }
'3' : { $build = '-b04' }
'2' : { $build = '-b13' }
'1' : { $build = '-b08' }
'0' : { $build = '' }
default : { fail("Unexisting update number ${min_version}") }
}
}
default : {
fail("Unsupported or unexisting version ${version}")
}
}

# remove extra particle if minor version is 0
$version_final = delete($version_real, 'u0')

# define installer filename and download URL
$filename = "${type}-${version_final}-linux-${arch}.rpm"
$downloadurl = "http://download.oracle.com/otn-pub/java/jdk/${version_final}${build}/${filename}"

# make sure install/download directory exists
file { '/usr/java':
ensure => directory,
mode => '0755',
owner => 'root',
group => 'root'
} ->
# download RPM
exec { 'downloadRPM':
path => '/usr/bin',
cwd => '/usr/java',
creates => "/usr/java/${filename}",
command => "wget --no-cookies --no-check-certificate --header \"Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie\" \"${downloadurl}\"",
timeout => 0
} ->
# install package
package { $type:
ensure => latest,
source => "/usr/java/${filename}",
provider => rpm
}
}

0 comments on commit 4d35821

Please sign in to comment.