Last active
July 12, 2016 08:21
-
-
Save fatmcgav/cbacf6380639301779ea894180a4568a to your computer and use it in GitHub Desktop.
Puppet Oracle Java RPM installation from Puppet fileserver source
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$java_major_version = '8' | |
$java_minor_version = '25' | |
$java_se = 'jdk' | |
$package_source = 'puppet:///packages/java' | |
class { '::base::software::java': | |
maj_version => $java_major_version, | |
min_version => $java_minor_version, | |
se => $java_se, | |
source => $package_source | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ tree /data/ | |
/data/ | |
└── java | |
└── jdk-8u25-linux-x64.rpm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[packages] | |
path /data | |
allow * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class base::software::java ( | |
$min_version, | |
$distribution = 'oracle', | |
$maj_version = '8', | |
$se = 'jdk', | |
$source = undef | |
) { | |
# Validate inputs | |
validate_re($distribution, 'oracle|openjdk') | |
validate_re($se, 'jdk|jre') | |
validate_re($maj_version, '6|7|8') | |
# Build up a version identifier and package identifier | |
$package = "${se}-${maj_version}u${min_version}-linux-x64.rpm" | |
$version = "${se}1.${maj_version}.0_${min_version}" | |
# Source provided? | |
case $source { | |
/^puppet/: { | |
# Construct temp path | |
$package_path = "/tmp/${package}" | |
# Grab file from $source | |
file { 'java_package': | |
ensure => present, | |
path => $package_path, | |
source => $source | |
} | |
# Install package using RPM provider | |
package { $version: | |
ensure => present, | |
provider => 'rpm', | |
source => $package_path, | |
require => File['java_package'] | |
} | |
} | |
'yum': { | |
# Install using default package provider | |
package { $version: | |
ensure => present | |
} | |
} | |
# Fall back to using puppetlabs-java module | |
default: { | |
# Oracle or OpenJDK? | |
case $distribution { | |
'oracle': { | |
java::oracle { "oracle_${se}${maj_version}_${min_version}": | |
ensure => present, | |
version => $maj_version, | |
java_se => $se | |
} | |
} | |
'openjdk': { | |
class { '::java': | |
distribution => $se, | |
version => $version | |
} | |
contain ::java | |
} | |
default: {} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment