diff --git a/manifests/first.pp b/manifests/first.pp
index c6040b7..a124857 100644
--- a/manifests/first.pp
+++ b/manifests/first.pp
@@ -8,7 +8,7 @@
ensure => latest,
}
-$my_dirs = [ "/opt/installations", "/opt/sources" ]
+$my_dirs = [ "/opt/installations", "/opt/sources", "/opt/sources/dspace", "/opt/installations/dspace" ]
file { $my_dirs:
ensure => directory,
}
@@ -24,3 +24,10 @@
target => '/opt/sources',
require => File['/opt/sources'],
}
+
+class { 'jdk_oracle':
+ ensure => installed,
+ version => '8',
+ install_dir => '/installations/java',
+ require => File['/installations'],
+}
diff --git a/modules/jdk_oracle/LICENSE b/modules/jdk_oracle/LICENSE
new file mode 100644
index 0000000..7a7258a
--- /dev/null
+++ b/modules/jdk_oracle/LICENSE
@@ -0,0 +1,13 @@
+Copyright 2013 Tyler Walters
+
+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.
diff --git a/modules/jdk_oracle/Modulefile b/modules/jdk_oracle/Modulefile
new file mode 100644
index 0000000..4dee8fb
--- /dev/null
+++ b/modules/jdk_oracle/Modulefile
@@ -0,0 +1,8 @@
+name 'tylerwalts-jdk_oracle'
+version '1.3.3'
+source 'https://github.com/tylerwalts/puppet-jdk_oracle'
+author 'tylerwalts'
+license 'Apache License, Version 2.0'
+summary 'Module for automating Oracle JDK download and installation'
+description 'Module for automating Oracle JDK download and installation, which does not have a dependency on a human download task, file share or centralized architecture design. It fetches the installer binary from the target server, for the target server. This approach assumes that automation is more valuable than bandwidth.'
+project_page 'https://github.com/tylerwalts/puppet-jdk_oracle'
diff --git a/modules/jdk_oracle/README.md b/modules/jdk_oracle/README.md
new file mode 100644
index 0000000..14ba1ed
--- /dev/null
+++ b/modules/jdk_oracle/README.md
@@ -0,0 +1,113 @@
+# puppet-jdk_oracle
+
+[![Build Status](https://travis-ci.org/tylerwalts/puppet-jdk_oracle.png?branch=master)](https://travis-ci.org/tylerwalts/puppet-jdk_oracle)
+
+## Overview
+
+Puppet module to automate fetching and installing the Oracle JDK from the Oracle-hosted download site located here: http://www.oracle.com/technetwork/java/javase/downloads/index.html
+
+_Note: By using this module you will automatically accept the Oracle agreement to download Java._
+
+There are several puppet modules available that will help install Oracle JDK, but they either use the local package manager repository, or depend on the user to manually place the Oracle Java installer in the module's file directory prior to using. This module will use wget with a cookie to automatically grab the installer from Oracle.
+
+This approach was inspired by: http://stackoverflow.com/questions/10268583/how-to-automate-download-and-instalation-of-java-jdk-on-linux
+
+### Supported Operating Systems:
+* RedHat Family (RedHat, Fedora, CentOS)
+* Debian Family (Ubuntu)
+* SUSE
+* _This may work on other linux flavors but more testing is needed. Please send feedback!_
+
+### Supported Java Versions:
+* Java 6, 7, 8
+* Build versions should be specified as parameters (see below)
+
+#### Reasons you may want to use this module:
+
+1. You do not control or trust your package repository to host the version of Oracle Java that you want.
+1. You want to lock in the version that gets installed.
+1. You want to use Oracle’s CDN to host the binary instead of hosting it yourself.
+
+#### Reasons why you would not want to use this module:
+
+1. If you want to use package management (.deb, .rpm) instead of extracting a generic archive.
+ 1. Consider schrepfler’s fork which does RPM without v6: https://github.com/schrepfler/puppet-jdk_oracle
+1. If you want to rely on your package repository to host the binary, not Oracle.
+1. If your target configuration server does not have access to the Internet. Assumes the server can pull it.
+
+
+## Installation:
+
+### A) Traditional:
+* Copy this project into your puppet modules path and rename to "jdk_oracle"
+
+### B) Puppet Librarian:
+* Put this in your Puppetfile:
+From Forge:
+```
+mod "tylerwalts/jdk_oracle"
+```
+
+From Source:
+```
+ mod "jdk_oracle",
+ :git => "git://github.com/tylerwalts/puppet-jdk_oracle.git"
+```
+
+
+## Usage:
+
+### A) Traditional:
+```
+ include jdk_oracle
+```
+or
+```
+ class { 'jdk_oracle': }
+```
+
+
+### B) Hiera:
+config.json:
+```
+ {
+ classes":[
+ "jdk_oracle"
+ ]
+ }
+```
+OR
+config.yaml:
+```
+---
+ classes:
+ - "jdk_oracle"
+ jdk_oracle::version: "6"
+```
+
+site.pp:
+```
+ hiera_include("classes", [])
+```
+
+
+## Parameters:
+
+* version
+ * Java Version to install
+* version_update
+ * Java Version update to install
+* version_build
+ * Java Version build to install
+* install_dir
+ * Java Installation Directory
+* use_cache
+ * Optionally host the installer file locally instead of fetching it each time, for faster dev & test
+* platform
+ * The platform to use
+* default_java
+ * Boolean to indicate if the installed java version is linked as the default java, javac etc...
+* ensure
+ * Boolean to disable anything from happening (absent/removal not supported yet)
+
+
diff --git a/modules/jdk_oracle/Rakefile b/modules/jdk_oracle/Rakefile
new file mode 100644
index 0000000..6143b61
--- /dev/null
+++ b/modules/jdk_oracle/Rakefile
@@ -0,0 +1,4 @@
+require 'rubygems'
+require 'puppetlabs_spec_helper/rake_tasks'
+require 'puppet-lint'
+PuppetLint.configuration.send("disable_80chars")
diff --git a/modules/jdk_oracle/checksums.json b/modules/jdk_oracle/checksums.json
new file mode 100644
index 0000000..bdbeb5b
--- /dev/null
+++ b/modules/jdk_oracle/checksums.json
@@ -0,0 +1,12 @@
+{
+ "LICENSE": "04710a89087f7051fd6f26539353f14d",
+ "Modulefile": "0dccf1e4c4e1e234ebe7e1a44211283e",
+ "README.md": "6217d334dc8d8f0eb493886d9a4499fb",
+ "Rakefile": "4617b1db6b164cda36fa92014ffa4950",
+ "manifests/init.pp": "ae545989954a58b3611ff508bdd8f106",
+ "manifests/init.pp.bak": "33b6f5a5bda248a56aeba5bcb9708518",
+ "manifests/suse.pp": "7823cbadaa002f42c54f04adbff8063d",
+ "metadata.json": "891fbfbec7f6ae8b43245e258528af26",
+ "spec/classes/jdk_oracle_init_spec.rb": "976ef32821f12cd95e7878094843e2f8",
+ "spec/spec_helper.rb": "e2557d7a809dccb72606febaf0757c50"
+}
\ No newline at end of file
diff --git a/modules/jdk_oracle/files/.gitignore b/modules/jdk_oracle/files/.gitignore
new file mode 100644
index 0000000..f271194
--- /dev/null
+++ b/modules/jdk_oracle/files/.gitignore
@@ -0,0 +1,2 @@
+jdk-*-linux-*.tar.gz
+
diff --git a/modules/jdk_oracle/manifests/init.pp b/modules/jdk_oracle/manifests/init.pp
new file mode 100644
index 0000000..7638303
--- /dev/null
+++ b/modules/jdk_oracle/manifests/init.pp
@@ -0,0 +1,258 @@
+# == Class: jdk_oracle
+#
+# Installs the Oracle Java JDK, from the Oracle servers
+#
+# === Parameters
+#
+# [*version*]
+# String. Java Version to install
+# Defaults to 8.
+#
+# [*version_update*]
+# String. Java Version Update to install
+# Defaults to Defaults based on major version.
+#
+# [*version_build*]
+# String. Java Version build to install
+# Defaults to Defaults based on major version.
+#
+# [* java_install_dir *]
+# String. Java Installation Directory
+# Defaults to /opt.
+#
+# [* use_cache *]
+# Boolean. Optionally host the installer file locally instead of fetching it each time (for faster dev & test)
+# The puppet cache flag is for faster local vagrant development, to
+# locally host the tarball from oracle instead of fetching it each time.
+# Defaults to false.
+#
+# [* platform *]
+# String. The platform to use
+# Defaults to x64.
+#
+# [* default_java *]
+# Boolean. If the installed java version is linked as the default java, javac etc...
+# Defaults to true.
+#
+# [* ensure *]
+# String. Specifies if jdk should be installed or absent
+# Defaults to installed.
+#
+class jdk_oracle(
+ $version = hiera('jdk_oracle::version', '8' ),
+ $version_update = hiera('jdk_oracle::version_update', 'default' ),
+ $version_build = hiera('jdk_oracle::version_build', 'default' ),
+ $install_dir = hiera('jdk_oracle::install_dir', '/opt' ),
+ $use_cache = hiera('jdk_oracle::use_cache', false ),
+ $cache_source = 'puppet:///modules/jdk_oracle/',
+ $platform = hiera('jdk_oracle::platform', 'x64' ),
+ $default_java = hiera('jdk_oracle::default_java', true ),
+ $ensure = 'installed'
+ ) {
+
+ $default_8_update = '11'
+ $default_8_build = '12'
+ $default_7_update = '67'
+ $default_7_build = '01'
+ $default_6_update = '45'
+ $default_6_build = '06'
+
+ if $ensure == 'installed' {
+ # Set default exec path for this module
+ Exec { path => ['/usr/bin', '/usr/sbin', '/bin'] }
+
+ case $platform {
+ 'x64': { $plat_filename = 'x64' }
+ 'x86': { $plat_filename = 'i586' }
+ default: { fail("Unsupported platform: ${platform}. Implement me?") }
+ }
+
+ case $version {
+ '8': {
+ if ($version_update != 'default') {
+ $version_u = $version_update
+ } else {
+ $version_u = $default_8_update
+ }
+ if ($version_build != 'default'){
+ $version_b = $version_build
+ } else {
+ $version_b = $default_8_build
+ }
+ $javaDownloadURI = "http://download.oracle.com/otn-pub/java/jdk/${version}u${version_u}-b${version_b}/jdk-${version}u${version_u}-linux-${plat_filename}.tar.gz"
+ $java_home = "${install_dir}/jdk1.${version}.0_${version_u}"
+ }
+ '7': {
+ if ($version_update != 'default'){
+ $version_u = $version_update
+ } else {
+ $version_u = $default_7_update
+ }
+ if ($version_build != 'default'){
+ $version_b = $version_build
+ } else {
+ $version_b = $default_7_build
+ }
+ $javaDownloadURI = "http://download.oracle.com/otn-pub/java/jdk/${version}u${version_u}-b${version_b}/jdk-${version}u${version_u}-linux-${plat_filename}.tar.gz"
+ $java_home = "${install_dir}/jdk1.${version}.0_${version_u}"
+ }
+ '6': {
+ if ($version_update != 'default'){
+ $version_u = $version_update
+ } else {
+ $version_u = $default_6_update
+ }
+ if ($version_build != 'default'){
+ $version_b = $version_build
+ } else {
+ $version_b = $default_6_build
+ }
+ $javaDownloadURI = "https://edelivery.oracle.com/otn-pub/java/jdk/${version}u${version_u}-b${version_b}/jdk-${version}u${version_u}-linux-${plat_filename}.bin"
+ $java_home = "${install_dir}/jdk1.${version}.0_${version_u}"
+ }
+ default: {
+ fail("Unsupported version: ${version}. Implement me?")
+ }
+ }
+
+ if ! defined(File[$install_dir]) {
+ file { $install_dir:
+ ensure => directory,
+ }
+ }
+
+ $installerFilename = inline_template('<%= File.basename(@javaDownloadURI) %>')
+
+ if ( $use_cache ){
+ file { "${install_dir}/${installerFilename}":
+ source => "${cache_source}${installerFilename}",
+ require => File[$install_dir],
+ } ->
+ exec { 'get_jdk_installer':
+ cwd => $install_dir,
+ creates => "${install_dir}/jdk_from_cache",
+ command => 'touch jdk_from_cache',
+ }
+ } else {
+ exec { 'get_jdk_installer':
+ cwd => $install_dir,
+ creates => "${install_dir}/${installerFilename}",
+ command => "wget -c --no-cookies --no-check-certificate --header \"Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com\" --header \"Cookie: oraclelicense=accept-securebackup-cookie\" \"${javaDownloadURI}\" -O ${installerFilename}",
+ timeout => 600,
+ require => Package['wget'],
+ }
+
+ file { "${install_dir}/${installerFilename}":
+ mode => '0755',
+ require => Exec['get_jdk_installer'],
+ }
+
+ if ! defined(Package['wget']) {
+ package { 'wget':
+ ensure => present,
+ }
+ }
+ }
+
+ # Java 7/8 comes in a tarball so just extract it.
+ if ( $version in [ '7', '8' ] ) {
+ exec { 'extract_jdk':
+ cwd => "${install_dir}/",
+ command => "tar -xf ${installerFilename}",
+ creates => $java_home,
+ require => Exec['get_jdk_installer'],
+ }
+ }
+ # Java 6 comes as a self-extracting binary
+ if ( $version == '6' ) {
+ exec { 'extract_jdk':
+ cwd => "${install_dir}/",
+ command => "${install_dir}/${installerFilename}",
+ creates => $java_home,
+ require => File["${install_dir}/${installerFilename}"],
+ }
+ }
+
+ # Ensure that files belong to root
+ file {$java_home:
+ recurse => true,
+ owner => root,
+ group => root,
+ subscribe => Exec['extract_jdk'],
+ }
+
+ # Set links depending on osfamily or operating system fact
+ case $::osfamily {
+ RedHat, Linux: {
+ if ( $default_java ) {
+ file { '/etc/alternatives/java':
+ ensure => link,
+ target => "${java_home}/bin/java",
+ require => Exec['extract_jdk'],
+ }
+ file { '/etc/alternatives/javac':
+ ensure => link,
+ target => "${java_home}/bin/javac",
+ require => Exec['extract_jdk'],
+ }
+ file { '/usr/sbin/java':
+ ensure => link,
+ target => '/etc/alternatives/java',
+ require => File['/etc/alternatives/java'],
+ }
+ file { '/usr/sbin/javac':
+ ensure => link,
+ target => '/etc/alternatives/javac',
+ require => File['/etc/alternatives/javac'],
+ }
+ }
+ file { "${install_dir}/java_home":
+ ensure => link,
+ target => $java_home,
+ require => Exec['extract_jdk'],
+ }
+ file { "${install_dir}/jdk-${version}":
+ ensure => link,
+ target => $java_home,
+ require => Exec['extract_jdk'],
+ }
+ }
+ Debian: {
+ #Accommodate variations in default install locations for some variants of Debian
+ $path_to_updatealternatives_tool = $::lsbdistdescription ? {
+ /Ubuntu 14\.04.*/ => '/usr/bin/update-alternatives',
+ default => '/usr/sbin/update-alternatives',
+ }
+
+ if ( $default_java ) {
+ exec { "${path_to_updatealternatives_tool} --install /usr/bin/java java ${java_home}/bin/java 20000":
+ require => Exec['extract_jdk'],
+ unless => "test $(readlink /etc/alternatives/java) = '${java_home}/bin/java'",
+ }
+ exec { "${path_to_updatealternatives_tool} --install /usr/bin/javac javac ${java_home}/bin/javac 20000":
+ require => Exec['extract_jdk'],
+ unless => "test $(/bin/readlink /etc/alternatives/javac) = '${java_home}/bin/javac'",
+ }
+ augeas { 'environment':
+ context => '/files/etc/environment',
+ changes => [
+ "set JAVA_HOME ${java_home}",
+ ],
+ }
+ }
+ }
+ Suse: {
+ if ( $default_java ) {
+ class { 'jdk_oracle::suse' :
+ version => $version,
+ version_u => $version_u,
+ version_b => $version_b,
+ java_home => $java_home,
+ }
+ }
+ }
+
+ default: { fail('Unsupported OS, implement me?') }
+ }
+ }
+}
diff --git a/modules/jdk_oracle/manifests/init.pp.bak b/modules/jdk_oracle/manifests/init.pp.bak
new file mode 100644
index 0000000..874e92f
--- /dev/null
+++ b/modules/jdk_oracle/manifests/init.pp.bak
@@ -0,0 +1,225 @@
+# == Class: jdk_oracle
+#
+# Installs the Oracle Java JDK, from the Oracle servers
+#
+# === Parameters
+#
+# [*version*]
+# String. Java Version to install
+# Defaults to 8.
+#
+# [*version_update*]
+# String. Java Version Update to install
+# Defaults to Defaults based on major version.
+#
+# [*version_build*]
+# String. Java Version build to install
+# Defaults to Defaults based on major version.
+#
+# [* java_install_dir *]
+# String. Java Installation Directory
+# Defaults to /opt.
+#
+# [* use_cache *]
+# String. Optionally host the installer file locally instead of fetching it each time (for faster dev & test)
+# The puppet cache flag is for faster local vagrant development, to
+# locally host the tarball from oracle instead of fetching it each time.
+# Defaults to false.
+#
+# [* platform *]
+# String. The platform to use
+# Defaults to x64.
+#
+# [* ensure *]
+# String. Specifies if jdk should be installed or absent
+# Defaults to installed.
+#
+class jdk_oracle(
+ $version = hiera('jdk_oracle::version', '8' ),
+ $version_update = hiera('jdk_oracle::version_update', 'default' ),
+ $version_build = hiera('jdk_oracle::version_build', 'default' ),
+ $install_dir = hiera('jdk_oracle::install_dir', '/opt' ),
+ $use_cache = hiera('jdk_oracle::use_cache', false ),
+ $cache_source = 'puppet:///modules/jdk_oracle/',
+ $platform = hiera('jdk_oracle::platform', 'x64' ),
+ $ensure = 'installed'
+ ) {
+
+ $default_8_update = '11'
+ $default_8_build = '12'
+ $default_7_update = '67'
+ $default_7_build = '01'
+ $default_6_update = '45'
+ $default_6_build = '06'
+
+ if $ensure == 'installed' {
+ # Set default exec path for this module
+ Exec { path => ['/usr/bin', '/usr/sbin', '/bin'] }
+
+ case $platform {
+ 'x64': { $plat_filename = 'x64' }
+ 'x86': { $plat_filename = 'i586' }
+ default: { fail("Unsupported platform: ${platform}. Implement me?") }
+ }
+
+ case $version {
+ '8': {
+ if ($version_update != 'default') {
+ $version_u = $version_update
+ } else {
+ $version_u = $default_8_update
+ }
+ if ($version_build != 'default'){
+ $version_b = $version_build
+ } else {
+ $version_b = $default_8_build
+ }
+ $javaDownloadURI = "http://download.oracle.com/otn-pub/java/jdk/${version}u${version_u}-b${version_b}/jdk-${version}u${version_u}-linux-${plat_filename}.tar.gz"
+ $java_home = "${install_dir}/jdk1.${version}.0_${version_u}"
+ }
+ '7': {
+ if ($version_update != 'default'){
+ $version_u = $version_update
+ } else {
+ $version_u = $default_7_update
+ }
+ if ($version_build != 'default'){
+ $version_b = $version_build
+ } else {
+ $version_b = $default_7_build
+ }
+ $javaDownloadURI = "http://download.oracle.com/otn-pub/java/jdk/${version}u${version_u}-b${version_b}/jdk-${version}u${version_u}-linux-${plat_filename}.tar.gz"
+ $java_home = "${install_dir}/jdk1.${version}.0_${version_u}"
+ }
+ '6': {
+ if ($version_update != 'default'){
+ $version_u = $version_update
+ } else {
+ $version_u = $default_6_update
+ }
+ if ($version_build != 'default'){
+ $version_b = $version_build
+ } else {
+ $version_b = $default_6_build
+ }
+ $javaDownloadURI = "https://edelivery.oracle.com/otn-pub/java/jdk/${version}u${version_u}-b${version_b}/jdk-${version}u${version_u}-linux-${plat_filename}.bin"
+ $java_home = "${install_dir}/jdk1.${version}.0_${version_u}"
+ }
+ default: {
+ fail("Unsupported version: ${version}. Implement me?")
+ }
+ }
+
+ if ! defined(File["${install_dir}"]) {
+ file { "${install_dir}":
+ ensure => directory,
+ }
+ }
+
+ $installerFilename = inline_template('<%= File.basename(@javaDownloadURI) %>')
+
+ if ( $use_cache ){
+ notify { 'Using local cache for oracle java': }
+ file { "${install_dir}/${installerFilename}":
+ source => "${cache_source}${installerFilename}",
+ require => File["${install_dir}"],
+ } ->
+ exec { 'get_jdk_installer':
+ cwd => $install_dir,
+ creates => "${install_dir}/jdk_from_cache",
+ command => 'touch jdk_from_cache',
+ }
+ } else {
+ exec { 'get_jdk_installer':
+ cwd => $install_dir,
+ creates => "${install_dir}/${installerFilename}",
+ command => "wget -c --no-cookies --no-check-certificate --header \"Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com\" --header \"Cookie: oraclelicense=accept-securebackup-cookie\" \"${javaDownloadURI}\" -O ${installerFilename}",
+ timeout => 600,
+ require => Package['wget'],
+ }
+
+ file { "${install_dir}/${installerFilename}":
+ mode => '0755',
+ require => Exec['get_jdk_installer'],
+ }
+
+ if ! defined(Package['wget']) {
+ package { 'wget':
+ ensure => present,
+ }
+ }
+ }
+
+ # Java 7/8 comes in a tarball so just extract it.
+ if ( $version in [ '7', '8' ] ) {
+ exec { 'extract_jdk':
+ cwd => "${install_dir}/",
+ command => "tar -xf ${installerFilename}",
+ creates => $java_home,
+ require => Exec['get_jdk_installer'],
+ }
+ }
+ # Java 6 comes as a self-extracting binary
+ if ( $version == '6' ) {
+ exec { 'extract_jdk':
+ cwd => "${install_dir}/",
+ command => "${install_dir}/${installerFilename}",
+ creates => $java_home,
+ require => File["${install_dir}/${installerFilename}"],
+ }
+ }
+
+ # Set links depending on osfamily or operating system fact
+ case $::osfamily {
+ RedHat, Linux: {
+ file { '/etc/alternatives/java':
+ ensure => link,
+ target => "${java_home}/bin/java",
+ require => Exec['extract_jdk'],
+ }
+ file { '/etc/alternatives/javac':
+ ensure => link,
+ target => "${java_home}/bin/javac",
+ require => Exec['extract_jdk'],
+ }
+ file { '/usr/sbin/java':
+ ensure => link,
+ target => '/etc/alternatives/java',
+ require => File['/etc/alternatives/java'],
+ }
+ file { '/usr/sbin/javac':
+ ensure => link,
+ target => '/etc/alternatives/javac',
+ require => File['/etc/alternatives/javac'],
+ }
+ file { "${install_dir}/java_home":
+ ensure => link,
+ target => $java_home,
+ require => Exec['extract_jdk'],
+ }
+ file { "${install_dir}/jdk-${version}":
+ ensure => link,
+ target => $java_home,
+ require => Exec['extract_jdk'],
+ }
+ }
+ Debian: {
+ exec { "/usr/sbin/update-alternatives --install /usr/bin/java java ${java_home}/bin/java 20000":
+ require => Exec['extract_jdk'],
+ unless => "test $(readlink /etc/alternatives/java) = '${java_home}/bin/java'",
+ }
+ exec { "/usr/sbin/update-alternatives --install /usr/bin/javac javac ${java_home}/bin/javac 20000":
+ require => Exec['extract_jdk'],
+ unless => "test $(/bin/readlink /etc/alternatives/javac) = '${java_home}/bin/javac'",
+ }
+ augeas { 'environment':
+ context => '/files/etc/environment',
+ changes => [
+ "set JAVA_HOME ${java_home}",
+ ],
+ }
+ }
+ default: { fail('Unsupported OS, implement me?') }
+ }
+ }
+}
diff --git a/modules/jdk_oracle/manifests/suse.pp b/modules/jdk_oracle/manifests/suse.pp
new file mode 100644
index 0000000..d5acf6a
--- /dev/null
+++ b/modules/jdk_oracle/manifests/suse.pp
@@ -0,0 +1,247 @@
+# == Class: jdk_oracle::suse
+#
+# Creates links, directories and alternatives for Suse
+#
+# === Parameters
+#
+class jdk_oracle::suse {
+
+ $java_home_loc = $jdk_oracle::java_home
+
+ # Make the update-alternatives priority integer based on version, version_u, version_b
+ $ua_priority = $jdk_oracle::version * 1000000 + $jdk_oracle::version_u * 1000 + $jdk_oracle::version_b
+
+ # These need to be created, and the paths used later
+ $libjvm_root = '/usr/lib64/jvm'
+ $export_root = '/usr/lib64/jvm-exports'
+
+ file { [ $libjvm_root, $export_root ] :
+ ensure => directory,
+ require => Exec['extract_jdk'],
+ }
+
+ # To put the update-alternatives links in the right place
+ $java_home_basename = inline_template('<%= File.basename(@java_home_loc) %>')
+ $export_dir = "${export_root}/${java_home_basename}"
+
+ file { $export_dir:
+ ensure => directory,
+ path => $export_dir,
+ require => File[$export_root],
+ }
+
+ # Oracle-specific symlinks are versioned like so
+ $export_version = "1.${jdk_oracle::version}.0"
+
+ # Do all of the symlinks to jvm-exports
+ file { "${export_dir}/jaas-${export_version}_Orac.jar" :
+ ensure => link,
+ target => "${java_home_loc}/jre/lib/rt.jar",
+ require => File[ $export_dir ],
+ } ->
+ file { "${export_dir}/jaas-${export_version}.jar" :
+ ensure => link,
+ target => "${export_dir}/jaas-${export_version}_Orac.jar",
+ } ->
+ file { "${export_dir}/jaas.jar" :
+ ensure => link,
+ target => "${export_dir}/jaas-${export_version}_Orac.jar",
+ } ->
+ file { "${export_dir}/jce-${export_version}_Orac.jar" :
+ ensure => link,
+ target => "${java_home_loc}/jre/lib/jce.jar",
+ } ->
+ file { "${export_dir}/jce-${export_version}.jar" :
+ ensure => link,
+ target => "${export_dir}/jce-${export_version}_Orac.jar",
+ } ->
+ file { "${export_dir}/jce.jar" :
+ ensure => link,
+ target => "${export_dir}/jce-${export_version}_Orac.jar",
+ } ->
+ file { "${export_dir}/jdbc-stdext-${export_version}_Orac.jar" :
+ ensure => link,
+ target => "${java_home_loc}/jre/lib/rt.jar",
+ } ->
+ file { "${export_dir}/jdbc-stdext-${export_version}.jar" :
+ ensure => link,
+ target => "${export_dir}/jdbc-stdext-${export_version}_Orac.jar",
+ } ->
+ file { "${export_dir}/jdbc-stdext-3.0.jar" :
+ ensure => link,
+ target => "${export_dir}/jdbc-stdext-${export_version}_Orac.jar",
+ } ->
+ file { "${export_dir}/jdbc-stdext.jar" :
+ ensure => link,
+ target => "${export_dir}/jdbc-stdext-${export_version}_Orac.jar",
+ } ->
+ file { "${export_dir}/jndi-${export_version}_Orac.jar" :
+ ensure => link,
+ target => "${java_home_loc}/jre/lib/rt.jar",
+ } ->
+ file { "${export_dir}/jndi-${export_version}.jar" :
+ ensure => link,
+ target => "${export_dir}/jndi-${export_version}_Orac.jar",
+ } ->
+ file { "${export_dir}/jndi.jar" :
+ ensure => link,
+ target => "${export_dir}/jndi-${export_version}_Orac.jar",
+ } ->
+ file { "${export_dir}/jndi-cos-${export_version}_Orac.jar" :
+ ensure => link,
+ target => "${java_home_loc}/jre/lib/rt.jar",
+ } ->
+ file { "${export_dir}/jndi-cos-${export_version}.jar" :
+ ensure => link,
+ target => "${export_dir}/jndi-cos-${export_version}_Orac.jar",
+ } ->
+ file { "${export_dir}/jndi-cos.jar" :
+ ensure => link,
+ target => "${export_dir}/jndi-cos-${export_version}_Orac.jar",
+ } ->
+ file { "${export_dir}/jndi-ldap-${export_version}_Orac.jar" :
+ ensure => link,
+ target => "${java_home_loc}/jre/lib/rt.jar",
+ } ->
+ file { "${export_dir}/jndi-ldap-${export_version}.jar" :
+ ensure => link,
+ target => "${export_dir}/jndi-ldap-${export_version}_Orac.jar",
+ } ->
+ file { "${export_dir}/jndi-ldap.jar" :
+ ensure => link,
+ target => "${export_dir}/jndi-ldap-${export_version}_Orac.jar",
+ } ->
+ file { "${export_dir}/jndi-rmi-${export_version}_Orac.jar" :
+ ensure => link,
+ target => "${java_home_loc}/jre/lib/rt.jar",
+ } ->
+ file { "${export_dir}/jndi-rmi-${export_version}.jar" :
+ ensure => link,
+ target => "${export_dir}/jndi-rmi-${export_version}_Orac.jar",
+ } ->
+ file { "${export_dir}/jndi-rmi.jar" :
+ ensure => link,
+ target => "${export_dir}/jndi-rmi-${export_version}_Orac.jar",
+ } ->
+ file { "${export_dir}/jsse-${export_version}_Orac.jar" :
+ ensure => link,
+ target => "${java_home_loc}/jre/lib/jsse.jar",
+ } ->
+ file { "${export_dir}/jsse-${export_version}.jar" :
+ ensure => link,
+ target => "${export_dir}/jsse-${export_version}_Orac.jar",
+ } ->
+ file { "${export_dir}/jsse.jar" :
+ ensure => link,
+ target => "${export_dir}/jsse-${export_version}_Orac.jar",
+ } ->
+ file { "${export_dir}/sasl-${export_version}_Orac.jar" :
+ ensure => link,
+ target => "${java_home_loc}/jre/lib/rt.jar",
+ } ->
+ file { "${export_dir}/sasl-${export_version}.jar" :
+ ensure => link,
+ target => "${export_dir}/sasl-${export_version}_Orac.jar",
+ } ->
+ file { "${export_dir}/sasl.jar" :
+ ensure => link,
+ target => "${export_dir}/sasl-${export_version}_Orac.jar",
+ }
+
+
+ $alt_java = "\
+/usr/sbin/update-alternatives --install /usr/bin/java java ${java_home_loc}/bin/java ${ua_priority} \
+ --slave /usr/lib64/jvm/jre jre ${java_home_loc}/jre \
+ --slave /usr/lib64/jvm-exports/jre jre_exports /usr/lib64/jvm-exports/${java_home_basename} \
+ --slave /usr/bin/keytool keytool ${java_home_loc}/bin/keytool \
+ --slave /usr/bin/orbd orbd ${java_home_loc}/bin/orbd \
+ --slave /usr/bin/policytool policytool ${java_home_loc}/bin/policytool \
+ --slave /usr/bin/rmid rmid ${java_home_loc}/bin/rmid \
+ --slave /usr/bin/rmiregistry rmiregistry ${java_home_loc}/bin/rmiregistry \
+ --slave /usr/bin/servertool servertool ${java_home_loc}/bin/servertool \
+ --slave /usr/bin/tnameserv tnameserv ${java_home_loc}/bin/tnameserv \
+ --slave /usr/share/man/man1/java.1 java.1 ${java_home_loc}/man/man1/java.1 \
+ --slave /usr/share/man/man1/keytool.1 keytool.1 ${java_home_loc}/man/man1/keytool.1 \
+ --slave /usr/share/man/man1/orbd.1 orbd.1 ${java_home_loc}/man/man1/orbd.1 \
+ --slave /usr/share/man/man1/policytool.1 policytool.1 ${java_home_loc}/man/man1/policytool.1 \
+ --slave /usr/share/man/man1/rmid.1 rmid.1 ${java_home_loc}/man/man1/rmid.1 \
+ --slave /usr/share/man/man1/rmiregistry.1 rmiregistry.1 ${java_home_loc}/man/man1/rmiregistry.1 \
+ --slave /usr/share/man/man1/servertool.1 servertool.1 ${java_home_loc}/man/man1/servertool.1 \
+ --slave /usr/share/man/man1/tnameserv.1 tnameserv.1 ${java_home_loc}/man/man1/tnameserv.1 \
+"
+
+ $alt_javac = "\
+/usr/sbin/update-alternatives --install /usr/bin/javac javac ${java_home_loc}/bin/javac ${ua_priority} \
+--slave /usr/bin/appletviewer appletviewer ${java_home_loc}/bin/appletviewer \
+--slave /usr/bin/apt apt ${java_home_loc}/bin/apt \
+--slave /usr/bin/extcheck extcheck ${java_home_loc}/bin/extcheck \
+--slave /usr/bin/jar jar ${java_home_loc}/bin/jar \
+--slave /usr/bin/jarsigner jarsigner ${java_home_loc}/bin/jarsigner \
+--slave /usr/lib64/jvm/java java_sdk ${java_home_loc} \
+--slave /usr/lib64/jvm-exports/java java_sdk_exports /usr/lib64/jvm-exports/${java_home_basename} \
+--slave /usr/bin/javadoc javadoc ${java_home_loc}/bin/javadoc \
+--slave /usr/bin/javah javah ${java_home_loc}/bin/javah \
+--slave /usr/bin/javap javap ${java_home_loc}/bin/javap \
+--slave /usr/bin/jconsole jconsole ${java_home_loc}/bin/jconsole \
+--slave /usr/bin/jdb jdb ${java_home_loc}/bin/jdb \
+--slave /usr/bin/jhat jhat ${java_home_loc}/bin/jhat \
+--slave /usr/bin/jinfo jinfo ${java_home_loc}/bin/jinfo \
+--slave /usr/bin/jmap jmap ${java_home_loc}/bin/jmap \
+--slave /usr/bin/jps jps ${java_home_loc}/bin/jps \
+--slave /usr/bin/jrunscript jrunscript ${java_home_loc}/bin/jrunscript \
+--slave /usr/bin/jsadebugd jsadebugd ${java_home_loc}/bin/jsadebugd \
+--slave /usr/bin/jstack jstack ${java_home_loc}/bin/jstack \
+--slave /usr/bin/jstat jstat ${java_home_loc}/bin/jstat \
+--slave /usr/bin/jstatd jstatd ${java_home_loc}/bin/jstatd \
+--slave /usr/bin/native2ascii native2ascii ${java_home_loc}/bin/native2ascii \
+--slave /usr/bin/pack200 pack200 ${java_home_loc}/bin/pack200 \
+--slave /usr/bin/rmic rmic ${java_home_loc}/bin/rmic \
+--slave /usr/bin/schemagen schemagen ${java_home_loc}/bin/schemagen \
+--slave /usr/bin/serialver serialver ${java_home_loc}/bin/serialver \
+--slave /usr/bin/unpack200 unpack200 ${java_home_loc}/bin/unpack200 \
+--slave /usr/bin/wsgen wsgen ${java_home_loc}/bin/wsgen \
+--slave /usr/bin/wsimport wsimport ${java_home_loc}/bin/wsimport \
+--slave /usr/bin/xjc xjc ${java_home_loc}/bin/xjc \
+--slave /usr/share/man/man1/appletviewer.1 appletviewer.1 ${java_home_loc}/man/man1/appletviewer.1 \
+--slave /usr/share/man/man1/apt.1 apt.1 ${java_home_loc}/man/man1/apt.1 \
+--slave /usr/share/man/man1/extcheck.1 extcheck.1 ${java_home_loc}/man/man1/extcheck.1 \
+--slave /usr/share/man/man1/jar.1 jar.1 ${java_home_loc}/man/man1/jar.1 \
+--slave /usr/share/man/man1/jarsigner.1 jarsigner.1 ${java_home_loc}/man/man1/jarsigner.1 \
+--slave /usr/share/man/man1/javac.1 javac.1 ${java_home_loc}/man/man1/javac.1 \
+--slave /usr/share/man/man1/javadoc.1 javadoc.1 ${java_home_loc}/man/man1/javadoc.1 \
+--slave /usr/share/man/man1/javah.1 javah.1 ${java_home_loc}/man/man1/javah.1 \
+--slave /usr/share/man/man1/javap.1 javap.1 ${java_home_loc}/man/man1/javap.1 \
+--slave /usr/share/man/man1/jcmd.1 jcmd.1 ${java_home_loc}/man/man1/jcmd.1 \
+--slave /usr/share/man/man1/jconsole.1 jconsole.1 ${java_home_loc}/man/man1/jconsole.1 \
+--slave /usr/share/man/man1/jdb.1 jdb.1 ${java_home_loc}/man/man1/jdb.1 \
+--slave /usr/share/man/man1/jhat.1 jhat.1 ${java_home_loc}/man/man1/jhat.1 \
+--slave /usr/share/man/man1/jinfo.1 jinfo.1 ${java_home_loc}/man/man1/jinfo.1 \
+--slave /usr/share/man/man1/jmap.1 jmap.1 ${java_home_loc}/man/man1/jmap.1 \
+--slave /usr/share/man/man1/jps.1 jps.1 ${java_home_loc}/man/man1/jps.1 \
+--slave /usr/share/man/man1/jrunscript.1 jrunscript.1 ${java_home_loc}/man/man1/jrunscript.1 \
+--slave /usr/share/man/man1/jsadebugd.1 jsadebugd.1 ${java_home_loc}/man/man1/jsadebugd.1 \
+--slave /usr/share/man/man1/jstack.1 jstack.1 ${java_home_loc}/man/man1/jstack.1 \
+--slave /usr/share/man/man1/jstat.1 jstat.1 ${java_home_loc}/man/man1/jstat.1 \
+--slave /usr/share/man/man1/jstatd.1 jstatd.1 ${java_home_loc}/man/man1/jstatd.1 \
+--slave /usr/share/man/man1/native2ascii.1 native2ascii.1 ${java_home_loc}/man/man1/native2ascii.1 \
+--slave /usr/share/man/man1/pack200.1 pack200.1 ${java_home_loc}/man/man1/pack200.1 \
+--slave /usr/share/man/man1/rmic.1 rmic.1 ${java_home_loc}/man/man1/rmic.1 \
+--slave /usr/share/man/man1/schemagen.1 schemagen.1 ${java_home_loc}/man/man1/schemagen.1 \
+--slave /usr/share/man/man1/serialver.1 serialver.1 ${java_home_loc}/man/man1/serialver.1 \
+--slave /usr/share/man/man1/unpack200.1 unpack200.1 ${java_home_loc}/man/man1/unpack200.1 \
+--slave /usr/share/man/man1/wsgen.1 wsgen.1 ${java_home_loc}/man/man1/wsgen.1 \
+--slave /usr/share/man/man1/wsimport.1 wsimport.1 ${java_home_loc}/man/man1/wsimport.1 \
+--slave /usr/share/man/man1/xjc.1 xjc.1 ${java_home_loc}/man/man1/xjc.1 \
+"
+
+ exec { 'update_alternatives_java' :
+ command => $alt_java,
+ require => [ File[$libjvm_root], Exec['extract_jdk'] ],
+ unless => "test $(readlink /etc/alternatives/java) = '${java_home_loc}/bin/java'",
+ }
+ exec { 'update_alternatives_javac' :
+ command => $alt_javac,
+ require => [ File[$libjvm_root], Exec['extract_jdk'] ],
+ unless => "test $(readlink /etc/alternatives/java) = '${java_home_loc}/bin/java'",
+ }
+}
diff --git a/modules/jdk_oracle/metadata.json b/modules/jdk_oracle/metadata.json
new file mode 100644
index 0000000..7b52222
--- /dev/null
+++ b/modules/jdk_oracle/metadata.json
@@ -0,0 +1,43 @@
+{
+ "name": "tylerwalts-jdk_oracle",
+ "version": "1.3.3",
+ "author": "tylerwalts",
+ "summary": "Module for automating Oracle JDK download and installation",
+ "license": "Apache License, Version 2.0",
+ "source": "https://github.com/tylerwalts/puppet-jdk_oracle",
+ "project_page": "https://github.com/tylerwalts/puppet-jdk_oracle",
+ "issues_url": "https://github.com/tylerwalts/puppet-jdk_oracle/issues",
+ "dependencies": [
+
+ ],
+ "tags": [
+ "java",
+ "oracle",
+ "jdk"
+ ],
+ "operatingsystem_support": [
+ {
+ "operatingsystem": "RedHat",
+ "operatingsystemrelease": [
+ "5.0",
+ "6.0"
+ ]
+ },
+ {
+ "operatingsystem": "Amazon",
+ "operatingsystemrelease": [
+ "2013",
+ "2014"
+ ]
+ },
+ {
+ "operatingsystem": "Ubuntu",
+ "operatingsystemrelease": [
+ "13.10",
+ "12.04",
+ "10.04"
+ ]
+ }
+ ],
+ "description": "Module for automating Oracle JDK download and installation, which does not have a dependency on a human download task, file share or centralized architecture design. It fetches the installer binary from the target server, for the target server. This approach assumes that automation is more valuable than bandwidth."
+}
diff --git a/modules/jdk_oracle/spec/classes/jdk_oracle_init_spec.rb b/modules/jdk_oracle/spec/classes/jdk_oracle_init_spec.rb
new file mode 100644
index 0000000..484186e
--- /dev/null
+++ b/modules/jdk_oracle/spec/classes/jdk_oracle_init_spec.rb
@@ -0,0 +1,83 @@
+require 'spec_helper'
+
+describe 'jdk_oracle', :type => 'class' do
+
+
+ context 'When deploying on CentOS' do
+ let :facts do {
+ :operatingsystem => 'CentOS',
+ :osfamily => 'RedHat',
+ }
+ end
+
+ context 'with default parameters' do
+ it {
+ is_expected.to contain_exec( 'get_jdk_installer')
+ is_expected.to contain_exec('extract_jdk')
+ is_expected.to contain_file('/etc/alternatives/java').with({
+ :ensure => 'link',
+ })
+ is_expected.to contain_file('/opt/jdk-8').with({
+ :ensure => 'link',
+ })
+ }
+ end
+
+ context 'specifying version 6' do
+ let :params do {
+ :version => '6',
+ } end
+
+ it {
+ is_expected.to contain_exec( 'get_jdk_installer')
+ is_expected.to contain_exec('extract_jdk')
+ is_expected.to contain_file('/opt/jdk-6').with({
+ :ensure => 'link',
+ })
+ }
+ end
+
+ context 'specifying version 7' do
+ let :params do {
+ :version => '7',
+ } end
+
+ it {
+ is_expected.to contain_exec( 'get_jdk_installer')
+ is_expected.to contain_exec('extract_jdk')
+ is_expected.to contain_file('/etc/alternatives/java').with({
+ :ensure => 'link',
+ })
+ is_expected.to contain_file('/opt/jdk-7').with({
+ :ensure => 'link',
+ })
+ }
+ end
+
+ context 'using custom installation directory' do
+ let :params do {
+ :install_dir => '/my/path',
+ :version => '6',
+ } end
+
+ it {
+ is_expected.to contain_file("/my/path/jdk-6u45-linux-x64.bin")
+ is_expected.to contain_exec('extract_jdk')
+ }
+ end
+
+ context 'using cache source' do
+ let :params do {
+ :use_cache => true,
+ } end
+
+ it {
+ is_expected.to contain_file('/opt/jdk-8u11-linux-x64.tar.gz').with({
+ :source => 'puppet:///modules/jdk_oracle/jdk-8u11-linux-x64.tar.gz',
+ })
+ }
+ end
+
+ end
+
+end
diff --git a/modules/jdk_oracle/spec/spec_helper.rb b/modules/jdk_oracle/spec/spec_helper.rb
new file mode 100644
index 0000000..6fb6f02
--- /dev/null
+++ b/modules/jdk_oracle/spec/spec_helper.rb
@@ -0,0 +1,6 @@
+require 'rubygems'
+require 'puppetlabs_spec_helper/module_spec_helper'
+
+RSpec.configure do |config|
+ config.expose_current_running_example_as :example
+end
diff --git a/run.sh b/run.sh
index e297d9a..0a7811c 100755
--- a/run.sh
+++ b/run.sh
@@ -1,2 +1,2 @@
#!/bin/bash
-puppet apply manifests/first.pp --config $(dirname $0)/puppet.conf "$@"
+puppet apply manifests/first.pp --config $(dirname $0)/puppet.conf --modulepath ./modules "$@"