From e09792cea9b7d8bb6354cfad3cf6627a498d3e37 Mon Sep 17 00:00:00 2001 From: Jeff McCune Date: Thu, 16 Jun 2011 17:43:56 -0700 Subject: [PATCH 1/4] Add Debian based distro support. This change separates the package resource into an implementation class following the composite class pattern. In addition, the _real variables have been removed to prevent confusion. The validation functions have been updated to support a more clear regular expression. The debian package names are different, so conditional logic is required to set a debian based distro specific variable for the Java distribution name. While the puppet resources work, there is currently an issue on Lucid where the package REQUIRES interactive installation to accept the license agreement. This will need to be fixed for fully automated deployment on apt based systems. --- manifests/init.pp | 46 +++++++++++++++++++++++++++++-------- manifests/package_debian.pp | 28 ++++++++++++++++++++++ manifests/package_redhat.pp | 28 ++++++++++++++++++++++ 3 files changed, 92 insertions(+), 10 deletions(-) create mode 100644 manifests/package_debian.pp create mode 100644 manifests/package_redhat.pp diff --git a/manifests/init.pp b/manifests/init.pp index b009bf8..c107102 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -16,18 +16,44 @@ class java( $version = 'installed' ) { - # Cannot pass anonymous arrays to functions in 2.6.8 - $v_distribution = [ '^jre$', '^jdk$' ] - # Must compare string values, not booleans. - validate_re($version, '^[._0-9a-zA-Z:-]+$') - validate_re($distribution, $v_distribution) + validate_re($distribution, '^jdk$|^jre$') + validate_re($version, 'installed|^[._0-9a-zA-Z:-]+$') - $version_real = $version - $distribution_real = $distribution + anchor { 'java::begin': } + anchor { 'java::end': } + + case $operatingsystem { + + centos, redhat, oel: { + + class { 'java::package_redhat': + version => $version, + distribution => $distribution, + require => Anchor['java::begin'], + before => Anchor['java::end'], + } + + } + + debian, ubuntu: { + + $distribution_debian = $distribution ? { + jdk => 'sun-java6-jdk', + jre => 'sun-java6-jre', + } + class { 'java::package_debian': + version => $version, + distribution => $distribution_debian, + require => Anchor['java::begin'], + before => Anchor['java::end'], + } + + } + + default: { + fail("operatingsystem $operatingsystem is not supported") + } - package { 'java': - ensure => $version_real, - name => "${distribution_real}", } } diff --git a/manifests/package_debian.pp b/manifests/package_debian.pp new file mode 100644 index 0000000..117ff81 --- /dev/null +++ b/manifests/package_debian.pp @@ -0,0 +1,28 @@ +# Class: java::package_debian +# +# Implementation class of the Java package +# for debian based systems. +# +# This class is not meant to be used by the end user +# of the module. It is an implementation class +# of the composite Class[java] +# +# Parameters: +# +# Actions: +# +# Requires: +# +# Sample Usage: +# +class java::package_debian( + $version, + $distribution +) { + + package { 'java': + ensure => $version, + name => $distribution, + } + +} diff --git a/manifests/package_redhat.pp b/manifests/package_redhat.pp new file mode 100644 index 0000000..681d978 --- /dev/null +++ b/manifests/package_redhat.pp @@ -0,0 +1,28 @@ +# Class: java::package_redhat +# +# Implementation class of the Java package +# for redhat based systems. +# +# This class is not meant to be used by the end user +# of the module. It is an implementation class +# of the composite Class[java] +# +# Parameters: +# +# Actions: +# +# Requires: +# +# Sample Usage: +# +class java::package_redhat( + $version, + $distribution +) { + + package { 'java': + ensure => $version, + name => $distribution, + } + +} From 12544569fb1b8c27b3746ff4d9657735ba1b1b10 Mon Sep 17 00:00:00 2001 From: Jeff McCune Date: Thu, 16 Jun 2011 17:44:34 -0700 Subject: [PATCH 2/4] Update the module example test manifest This change provides a clear indication about how relationships are expected to be managed when the end user consumes the module. --- tests/init.pp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/init.pp b/tests/init.pp index 8be274b..4114e3b 100644 --- a/tests/init.pp +++ b/tests/init.pp @@ -1 +1,10 @@ -include java +node default { + + notify { "alpha": } -> + class { 'java': + distribution => 'jdk', + version => 'latest', + } -> + notify { "omega": } + +} From 8aa2053c9d45542f70edca5db27792ad3df4bb96 Mon Sep 17 00:00:00 2001 From: Jeff McCune Date: Thu, 16 Jun 2011 17:45:11 -0700 Subject: [PATCH 3/4] Update README for apt and rpm based platforms. Package management for Lucid requires the partner repository to be enabled. This change documents that fact. --- README.markdown | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 42a42b7..e677d8f 100644 --- a/README.markdown +++ b/README.markdown @@ -2,7 +2,14 @@ Manage the Java runtime for use with other application software. -Currently this simply deploys the package on Enterprise Linux based systems. +Currently this simply deploys the package on Enterprise Linux based systems and Debian based systems. + +Tested on: + + * Centos 5.6 + * Ubuntu 10.04 Lucid + +# RedHat Support # The Java runtime this module is designed to configure are the RPM's provided by Oracle and obtained by extracting them from the "bin" installers. @@ -14,3 +21,13 @@ Please download the installer from: * [Java Downloads](http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u25-download-346242.html) +# Ubuntu Support # + +## Lucid ## + +You need to have the partner repository enabled in order to install the Sun JDK or JRE. + + aptitude install python-software-properties + sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner" + aptitude update + From 0b541605e10cb8d26f64e6d12a638b847daee5aa Mon Sep 17 00:00:00 2001 From: Jeff McCune Date: Thu, 16 Jun 2011 17:47:56 -0700 Subject: [PATCH 4/4] Bump stdlib module dependency to 0.1.6 This change is required because the anchor resource type is not available in versions of puppetlabs-stdlib < 0.1.6 --- Modulefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modulefile b/Modulefile index ebec92b..4708fb7 100644 --- a/Modulefile +++ b/Modulefile @@ -8,4 +8,4 @@ description 'Manage the official Java runtime' project_page 'https://github.com/puppetlabs/puppetlabs-java' ## Add dependencies, if any: -dependency 'puppetlabs/stdlib', '>= 0.1.3' +dependency 'puppetlabs/stdlib', '>= 0.1.6'