Skip to content

Commit 80c8178

Browse files
committed
first commit
0 parents  commit 80c8178

14 files changed

Lines changed: 293 additions & 0 deletions

File tree

.project

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>java</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>com.puppetlabs.geppetto.pp.dsl.ui.modulefileBuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
</buildSpec>
19+
<natures>
20+
<nature>com.puppetlabs.geppetto.pp.dsl.ui.puppetNature</nature>
21+
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
22+
</natures>
23+
</projectDescription>

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
##2015-04-21 - Release - 1.0.0
2+
###Summary
3+
Initial release as PuppetForge module.
4+
5+
####Features
6+
See the README.markdown
7+
8+
####Bugfixes
9+
10+
####Known bugs
11+
* No known bugs

LICENSE

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Copyright (C) 2015 Dario Sestero
2+
3+
Dario Sestero can be contacted at: dsestero 'at' gmail 'dot' com
4+
5+
Licensed under the Creative Commons Attribution-Share Alike 4.0 International license (CC-BY-SA-4.0) (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://creativecommons.org/licenses/by-sa/4.0/legalcode
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.

README.markdown

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#java
2+
3+
####Table of Contents
4+
5+
1. [Overview](#overview)
6+
2. [Module Description - What the module does and why it is useful](#module-description)
7+
3. [Setup - The basics of getting started with java](#setup)
8+
* [What java affects](#what-java-affects)
9+
* [Setup requirements](#setup-requirements)
10+
* [Beginning with java](#beginning-with-java)
11+
4. [Usage - Configuration options and additional functionality](#usage)
12+
5. [Reference - An under-the-hood peek at what the module is doing and how](#reference)
13+
5. [Limitations - OS compatibility, etc.](#limitations)
14+
6. [Development - Guide for contributing to the module](#development)
15+
16+
##Overview
17+
18+
This is the java module. It allows to install Java OpenJDK and configure the default java alternative.
19+
20+
##Module Description
21+
22+
The module provides classes and defines to install Java OpenJDK and configure the java alternative on Ubuntu platforms.
23+
It allows to install multiple Java versions on the same node.
24+
25+
##Setup
26+
27+
###What java affects
28+
29+
The module install the OpenJDK package from the repositories and set up the alternative system for the java command.
30+
31+
If hiera defines a value for the parameter `java::java_default_version` the alternative system link for the command java is set to manual mode according to specified version. Otherwise it is left as it is.
32+
33+
###Setup Requirements
34+
35+
The module has no special requirements.
36+
37+
###Beginning with java
38+
39+
The module provides two classes to install Java OpenJDK 6 and 7 respectively. This is done, for example, by declarations as the following:
40+
41+
```
42+
include java_7
43+
```
44+
45+
##Usage
46+
47+
It is possible to install multiple versions of Java on a single node and to specify via hiera the default java to be set in the alternative system. An example hiera (JSON) declaration for a node could be as follows:
48+
49+
```
50+
{
51+
"classes" : [
52+
"java::java_6",
53+
"java::java_7"
54+
],
55+
"java::java_default_version" : "6"
56+
}
57+
```
58+
59+
##Reference
60+
61+
###`java::java_6`
62+
Installs OpenJDK-6 from the repositories.
63+
64+
###`java::java_7`
65+
Installs OpenJDK-6 from the repositories.
66+
67+
####Parameters
68+
69+
#####`java::java_default_version`
70+
If present in a JSON hiera file allows to set the default java command in the alternative system.
71+
72+
##Limitations
73+
74+
At the moment the module targets only OpenJDK on Ubuntu platforms. Specifically, it is tested only on Ubuntu 10.04 and 12.04 distributions, although probably it will work also on more recent versions.
75+
76+
##Development
77+
78+
If you need some feature please send me a (pull) request or send me an email at: dsestero 'at' gmail 'dot' com.
79+

Rakefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
require 'rubygems'
2+
require 'puppetlabs_spec_helper/rake_tasks'

manifests/config.pp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# = Define: java::config
2+
#
3+
# Configures Java.
4+
# It is intended to be called by java::java.
5+
#
6+
# == Actions:
7+
#
8+
# Sets up the default java according to the parameter <tt>java_default_version</tt> if it is not null.
9+
#
10+
# == Requires:
11+
# none
12+
#
13+
define java::config ($java_version = $title, $java_default_version) {
14+
if $java_default_version != undef and $java_version == $java_default_version {
15+
case $::operatingsystem {
16+
'Ubuntu' : {
17+
case $::operatingsystemrelease {
18+
'10.04' : {
19+
$javadir = "/usr/lib/jvm/java-${$java_version}-openjdk/jre/bin/java"
20+
}
21+
'12.04' : {
22+
$javadir = "/usr/lib/jvm/java-${$java_version}-openjdk-${::architecture}/jre/bin/java"
23+
}
24+
default : {
25+
fail("The ${module_name} module is not supported on ${::operatingsystem} release ${::operatingsystemrelease}")
26+
}
27+
}
28+
}
29+
default : {
30+
fail("The ${module_name} module is not supported on an ${::operatingsystem} distribution.")
31+
}
32+
}
33+
34+
exec { 'set_java':
35+
command => "/usr/sbin/update-alternatives --set java ${javadir}",
36+
unless => "ls -l /etc/alternatives/java | grep ${javadir}",
37+
}
38+
}
39+
}

manifests/init.pp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Define: java
2+
#
3+
# This module manages Java.
4+
#
5+
# Parameters:
6+
#
7+
# $java_version:: The java version. Possible values at this time are <tt>6</tt> and <tt>7</tt>.
8+
# Defaults to the resource's title.
9+
#
10+
# $java_default_version:: The java default version. Possible values at this time are <tt>6</tt> and <tt>7</tt>.
11+
# If different than +undef+ it will be used to configure the alternative system.
12+
# Defaults to +undef+.
13+
#
14+
# Actions:
15+
#
16+
# Declares all other defines in the java module needed for installing Java.
17+
# Currently, these consists of java::install, and java::config.
18+
# Furthermore, the module provides two classes ready for use for installing java-6 and java-7 using the defines.
19+
# If hiera defines a value for the parameter <tt>java_default_version</tt> on the target node the
20+
# command <tt>update-alternatives</tt> is issued to set the default java accordingly.
21+
#
22+
# Requires: see Modulefile
23+
#
24+
# Sample Usage:
25+
#
26+
# java {'6': }
27+
define java ($java_version = $title, $java_default_version = hiera('java::java_default_version', undef)) {
28+
java::install { $java_version:
29+
} -> java::config { $java_version:
30+
java_default_version => $java_default_version,
31+
}
32+
}

manifests/install.pp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# = Define: java::install
2+
#
3+
# Installs Java.
4+
# It is intended to be called by java::java.
5+
#
6+
# == Actions:
7+
#
8+
# Installs the Java package.
9+
#
10+
# == Requires:
11+
# none
12+
#
13+
define java::install ($java_version = $title) {
14+
$package_name = $java_version ? {
15+
6 => 'openjdk-6-jdk',
16+
7 => 'openjdk-7-jdk',
17+
default => undef,
18+
}
19+
20+
package { $package_name:
21+
ensure => installed,
22+
}
23+
}

manifests/java_6.pp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Class: java::java_6
2+
#
3+
# This class installs Java-6.
4+
#
5+
# Parameters:
6+
#
7+
# none
8+
#
9+
# Actions:
10+
#
11+
# Installs Java-6 by declaring the +java+ define.
12+
#
13+
# Requires: see Modulefile
14+
#
15+
# Sample Usage:
16+
#
17+
# include java::java_6
18+
class java::java_6 {
19+
20+
java {'6': }
21+
}

manifests/java_7.pp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Class: java::java_7
2+
#
3+
# This class installs Java-7.
4+
#
5+
# Parameters:
6+
#
7+
# none
8+
#
9+
# Actions:
10+
#
11+
# Installs Java-7 by declaring the +java+ define.
12+
#
13+
# Requires: see Modulefile
14+
#
15+
# Sample Usage:
16+
#
17+
# include java::java_7
18+
class java::java_7 {
19+
20+
java {'7': }
21+
}

0 commit comments

Comments
 (0)