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

Commit 4d35821

Browse files
committed
Initial commit
0 parents  commit 4d35821

File tree

5 files changed

+237
-0
lines changed

5 files changed

+237
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
###1.0.0
2+
3+
First forge release

LICENSE

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright 2014 Antoine Cotten
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.

Modulefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name 'aco-oracle_java'
2+
version '1.0.0'
3+
source 'git://github.com/tOnI0/aco-oracle_java.git'
4+
author 'Antoine Cotten'
5+
license 'Apache License, Version 2.0'
6+
summary 'Puppet module to install Oracle Java on RPM-based Linux systems'
7+
description 'This module installs Oracle JRE or JDK from official RPM packages'
8+
project_page 'https://github.com/tOnI0/aco-oracle_java'
9+
10+
## Add dependencies, if any:
11+
# dependency 'username/name', '>= 1.2.0'
12+
dependency 'puppetlabs/stdlib', '>=3.2.0'

README.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#oracle_java
2+
3+
####Table of Contents
4+
5+
1. [Overview](#overview)
6+
2. [Module Description](#module-description)
7+
3. [Setup](#setup)
8+
4. [Usage](#usage)
9+
5. [Limitations](#limitations)
10+
6. [Credits](#credits)
11+
7. [To Do](#to-do)
12+
13+
##Overview
14+
15+
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.
16+
17+
##Module description
18+
19+
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.
20+
21+
##Setup
22+
23+
oracle_java will affect the following parts of your system:
24+
25+
* jre/jdk package
26+
27+
Including the main class is enough to install the latest version of the Oracle JRE.
28+
29+
```puppet
30+
include ::oracle_java
31+
```
32+
33+
####A couple of examples
34+
35+
Install the latest release of the Java 7 SE JRE
36+
37+
```puppet
38+
class { '::oracle_java':
39+
version => 7
40+
}
41+
```
42+
43+
Install the latest available JDK
44+
45+
```puppet
46+
class { '::oracle_java':
47+
type => 'jdk'
48+
}
49+
```
50+
51+
Install a specific version of the JDK
52+
53+
```puppet
54+
class { '::oracle_java':
55+
version => '7u45',
56+
type => 'jdk'
57+
}
58+
```
59+
60+
##Usage
61+
62+
####Class: `oracle_java`
63+
64+
Primary class and entry point of the module.
65+
66+
**Parameters within `oracle_java`:**
67+
68+
#####`version`
69+
70+
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'
71+
72+
Note: a minor version of '0' (for example '8u0') matches the initial release of the selected Java SE series.
73+
74+
#####`type`
75+
76+
What envionment type to install. Valid values are 'jre' and 'jdk'. Defaults to 'jre'
77+
78+
##Limitations
79+
80+
* 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.
81+
* Works only on [RPM-based distributions](http://en.wikipedia.org/wiki/List_of_Linux_distributions#RPM-based)
82+
83+
##Credits
84+
85+
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/)
86+
87+
##To DO
88+
89+
* Allow the manipulation of Java related environment variables
90+
* Propose an alternative based on tar.gz archives, also available from Oracle's archives
91+
92+
Features request and contributions are always welcome!

manifests/init.pp

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# === Class: oracle_java
2+
#
3+
# This module installs Oracle Java from official RPM packages
4+
#
5+
# == Parameters
6+
#
7+
# $version:
8+
# Java SE version to install (valid format: 'major'u'minor' or just 'major')
9+
# $type:
10+
# envionment type to install (valid: 'jre'|'jdk')
11+
#
12+
# === Actions
13+
#
14+
# - Install Oracle jre/jdk
15+
#
16+
# === Requires
17+
#
18+
# - puppetlabs/stdlib module
19+
#
20+
# === Sample Usage:
21+
#
22+
# class { '::oracle_java':
23+
# version => '8u5',
24+
# type => 'jdk'
25+
# }
26+
#
27+
class oracle_java ($version = '8', $type = 'jre') {
28+
# translate system architecture to expected value
29+
case $::architecture {
30+
'x86_64' : { $arch = 'x64' }
31+
'x86' : { $arch = 'i586' }
32+
default : { fail("Unsupported architecture ${arch}") }
33+
}
34+
35+
# set to latest release if no minor version was provided
36+
if $version == '8' {
37+
$version_real = '8u5'
38+
} elsif $version == '7' {
39+
$version_real = '7u60'
40+
} else {
41+
$version_real = $version
42+
}
43+
44+
# get major/minor version numbers
45+
$array_version = split($version_real, 'u')
46+
$maj_version = $array_version[0]
47+
$min_version = $array_version[1]
48+
49+
# associate build number to release version
50+
case $maj_version {
51+
8 : {
52+
case $min_version {
53+
'5' : { $build = '-b13' }
54+
'0' : { $build = '-b132' }
55+
default : { fail("Unexisting update number ${min_version}") }
56+
}
57+
}
58+
7 : {
59+
case $min_version {
60+
'60' : { $build = '-b19' }
61+
'55' : { $build = '-b13' }
62+
'51' : { $build = '-b13' }
63+
'45' : { $build = '-b18' }
64+
'40' : { $build = '-b43' }
65+
'25' : { $build = '-b15' }
66+
'21' : { $build = '-b11' }
67+
'17' : { $build = '-b02' }
68+
'15' : { $build = '-b03' }
69+
'13' : { $build = '-b20' }
70+
'11' : { $build = '-b21' }
71+
'10' : { $build = '-b18' }
72+
'9' : { $build = '-b05' }
73+
'7' : { $build = '-b10' }
74+
'6' : { $build = '-b24' }
75+
'5' : { $build = '-b06' }
76+
'4' : { $build = '-b20' }
77+
'3' : { $build = '-b04' }
78+
'2' : { $build = '-b13' }
79+
'1' : { $build = '-b08' }
80+
'0' : { $build = '' }
81+
default : { fail("Unexisting update number ${min_version}") }
82+
}
83+
}
84+
default : {
85+
fail("Unsupported or unexisting version ${version}")
86+
}
87+
}
88+
89+
# remove extra particle if minor version is 0
90+
$version_final = delete($version_real, 'u0')
91+
92+
# define installer filename and download URL
93+
$filename = "${type}-${version_final}-linux-${arch}.rpm"
94+
$downloadurl = "http://download.oracle.com/otn-pub/java/jdk/${version_final}${build}/${filename}"
95+
96+
# make sure install/download directory exists
97+
file { '/usr/java':
98+
ensure => directory,
99+
mode => '0755',
100+
owner => 'root',
101+
group => 'root'
102+
} ->
103+
# download RPM
104+
exec { 'downloadRPM':
105+
path => '/usr/bin',
106+
cwd => '/usr/java',
107+
creates => "/usr/java/${filename}",
108+
command => "wget --no-cookies --no-check-certificate --header \"Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie\" \"${downloadurl}\"",
109+
timeout => 0
110+
} ->
111+
# install package
112+
package { $type:
113+
ensure => latest,
114+
source => "/usr/java/${filename}",
115+
provider => rpm
116+
}
117+
}

0 commit comments

Comments
 (0)