Skip to content
This repository was archived by the owner on Jun 11, 2019. It is now read-only.

Add spec tests #13

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions .fixtures.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
fixtures:
repositories:
"puppi": "git://github.com/example42/puppi.git"
"monitor": "git://github.com/example42/puppet-monitor.git"
"firewall": "git://github.com/example42/puppet-firewall.git"
"iptables": "git://github.com/example42/puppet-iptables.git"
"concat": "git://github.com/example42/puppet-concat.git"
concat:
repo: 'https://github.com/puppetlabs/puppetlabs-concat.git'
ref: '2.1.0'
puppi:
repo: 'https://github.com/example42/puppi.git'
ref: 'v2.1.13'
stdlib:
repo: 'https://github.com/puppetlabs/puppetlabs-stdlib.git'
ref: '4.6.0'
symlinks:
"java": "#{source_dir}"

java: "#{source_dir}"
70 changes: 50 additions & 20 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,61 @@
---
language: ruby

bundler_args: --without development

rvm:
- 1.8.7
- 1.9.3
- 2.1.4
script:
- "bundle exec rake lint spec SPEC_OPTS='--format documentation'"
- 2.0.0
- 2.1.0

env:
- PUPPET_VERSION="~> 2.7.0"
- PUPPET_VERSION="~> 3.0.0"
- PUPPET_VERSION="~> 3.1.0"
- PUPPET_VERSION="~> 3.8.0"
- PUPPET_VERSION="~> 4.2"
matrix:
- PUPPET_GEM_VERSION="~> 3.1.0"
- PUPPET_GEM_VERSION="~> 3.2.0"
- PUPPET_GEM_VERSION="~> 3.3.0"
- PUPPET_GEM_VERSION="~> 3.4.0"
- PUPPET_GEM_VERSION="~> 3.5.0"
- PUPPET_GEM_VERSION="~> 3.6.0"
- PUPPET_GEM_VERSION="~> 3.7.0"
- PUPPET_GEM_VERSION="~> 3.8.0"
- PUPPET_GEM_VERSION="~> 3" FUTURE_PARSER="yes"
- PUPPET_GEM_VERSION="~> 4.0.0"
- PUPPET_GEM_VERSION="~> 4.1.0"
- PUPPET_GEM_VERSION="~> 4.2.0"
- PUPPET_GEM_VERSION="~> 4.3.0"
- PUPPET_GEM_VERSION="~> 4.4.0"
- PUPPET_GEM_VERSION="~> 4"

sudo: false

script: 'bundle exec rake metadata_lint && bundle exec rake validate && bundle exec rake lint && SPEC_OPTS="--format documentation" bundle exec rake spec'

matrix:
fast_finish: true
exclude:
- rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 3.1.0"
- rvm: 2.1.0
env: PUPPET_GEM_VERSION="~> 3.1.0"
- rvm: 2.1.0
env: PUPPET_GEM_VERSION="~> 3.2.0"
- rvm: 2.1.0
env: PUPPET_GEM_VERSION="~> 3.3.0"
- rvm: 2.1.0
env: PUPPET_GEM_VERSION="~> 3.4.0"
- rvm: 1.8.7
env: PUPPET_VERSION="~> 4.2"
- rvm: 1.9.3
env: PUPPET_VERSION="~> 2.7.0"
- rvm: 2.1.4
env: PUPPET_VERSION="~> 2.7.0"
- rvm: 2.1.4
env: PUPPET_VERSION="~> 3.0.0"
- rvm: 2.1.4
env: PUPPET_VERSION="~> 3.1.0"
env: PUPPET_GEM_VERSION="~> 4.0.0"
- rvm: 1.8.7
env: PUPPET_GEM_VERSION="~> 4.1.0"
- rvm: 1.8.7
env: PUPPET_GEM_VERSION="~> 4.2.0"
- rvm: 1.8.7
env: PUPPET_GEM_VERSION="~> 4.3.0"
- rvm: 1.8.7
env: PUPPET_GEM_VERSION="~> 4.4.0"
- rvm: 1.8.7
env: PUPPET_GEM_VERSION="~> 4"

sudo: false
notifications:
email:
- [email protected]
email: false
34 changes: 24 additions & 10 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
source 'https://rubygems.org'

puppetversion = ENV['PUPPET_VERSION']
if puppetversion = ENV['PUPPET_GEM_VERSION']
gem 'puppet', puppetversion, :require => false
else
gem 'puppet', :require => false
end

is_ruby18 = RUBY_VERSION.start_with? '1.8'
gem 'metadata-json-lint'
gem 'puppetlabs_spec_helper', '>= 1.1.1'
gem 'facter', '>= 1.7.0'
gem 'rspec-puppet'
gem 'puppet-lint', :git => 'https://github.com/rodjek/puppet-lint.git'
gem 'puppet-lint-absolute_classname-check'
gem 'puppet-lint-alias-check'
gem 'puppet-lint-file_ensure-check'
gem 'puppet-lint-file_source_rights-check'
gem 'puppet-lint-leading_zero-check'
gem 'puppet-lint-spaceship_operator_without_tag-check'
gem 'puppet-lint-trailing_comma-check'
gem 'puppet-lint-unquoted_string-check'
gem 'puppet-lint-variable_contains_upcase'

if is_ruby18
gem 'rspec', "~> 3.1.0", :require => false
gem 'rake', '~> 10.5.0', :require => false
# rspec must be v2 for ruby 1.8.7
if RUBY_VERSION >= '1.8.7' and RUBY_VERSION < '1.9'
# rake >=11 does not support ruby 1.8.7
gem 'rspec', '~> 2.0'
gem 'rake', '~> 10.0'
end
gem 'puppet', puppetversion, :require => false
gem 'puppet-lint'
gem 'puppetlabs_spec_helper', '>= 0.1.0'
gem 'rspec-puppet'
gem 'metadata-json-lint'

group :development do
gem 'puppet-blacksmith'
Expand Down
25 changes: 19 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,25 @@
####Table of Contents

1. [Overview](#overview)
2. [Setup](#setup)
3. [Usage](#usage)
1. [Compatibility](#compatibility)
1. [Setup](#setup)
1. [Usage](#usage)


##Overview

This module installs java (JDK + JRE) versions

##Compatibility
Puppet v3 (with and without the future parser) and Puppet v4 with Ruby versions
1.8.7, 1.9.3, 2.0.0 and 2.1.0 where supported by Puppet.

* Debian 6
* EL 6
* Solaris 10
* Solaris 11
* Ubuntu 14.04

##Setup

###Setup Requirements
Expand All @@ -23,10 +34,12 @@ This module installs java (JDK + JRE) versions

The main class is used only.

class { 'java':
jdk => false, # default - whether to install the jdk or the jre only
version => '6', # Java version to install
}
```puppet
class { 'java':
jdk => false, # default - whether to install the jdk or the jre only
version => '6', # Java version to install
}
```

##Development

Expand Down
6 changes: 4 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
require 'rubygems'
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-lint'
require 'puppet-lint/tasks/puppet-lint'
PuppetLint.configuration.send("disable_80chars")
PuppetLint.configuration.send("disable_140chars")
PuppetLint.configuration.send('disable_class_parameter_defaults')
PuppetLint.configuration.relative = true
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"]
51 changes: 28 additions & 23 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -19,67 +19,73 @@
$bool_jdk=any2bool($jdk)
$bool_debug=any2bool($debug)

if $package != undef { validate_string($package) }
if $package_jdk != undef { validate_string($package_jdk) }

### Definition of some variables used in the module
$manage_package = $java::bool_absent ? {
$manage_package = $bool_absent ? {
true => 'absent',
false => 'present',
}
$manage_file = $java::bool_absent ? {
$manage_file = $bool_absent ? {
true => 'absent',
default => 'present',
}

$headless_suffix = $java::bool_headless ? {
validate_absolute_path($java_home_base)
validate_string($version)

$headless_suffix = $bool_headless ? {
true => '-headless',
default => '',
}
$real_package = $package ? {
'' => $::operatingsystem ? {
'' => $::operatingsystem ? {
/(?i:Ubuntu|Debian|Mint)/ => "openjdk-${version}-jre${headless_suffix}",
/(?i:SLES)/ => "java-1_${version}_0-ibm",
/(?i:OpenSuSE)/ => "java-1_${version}_0-openjdk",
/(?i:Solaris)/ => $::operatingsystemmajrelease ? {
'10' => "CSWjre${version}",
'11' => "jre-${version}",
'5' => "jre-${version}",
/(?i:Solaris)/ => $::operatingsystemmajrelease ? {
'10' => "CSWjre${version}",
'11' => "jre-${version}",
'5' => "jre-${version}",
},
default => "java-1.${version}.0-openjdk",
default => "java-1.${version}.0-openjdk",
},
default => $package,
}

$real_package_jdk = $package_jdk ? {
'' => $::operatingsystem ? {
'' => $::operatingsystem ? {
/(?i:Ubuntu|Debian|Mint)/ => "openjdk-${version}-jdk",
/(?i:SLES)/ => "java-1_${version}_0-ibm",
/(?i:OpenSuSE)/ => "java-1_${version}_0-openjdk-devel",
/(?i:Solaris)/ => $::operatingsystemmajrelease ? {
'10' => "CSWjdk${version}",
'11' => "jdk-${version}",
'5' => "jdk-${version}",
/(?i:Solaris)/ => $::operatingsystemmajrelease ? {
'10' => "CSWjdk${version}",
'11' => "jdk-${version}",
'5' => "jdk-${version}",
},
default => "java-1.${version}.0-openjdk-devel",
default => "java-1.${version}.0-openjdk-devel",
},
default => $package_jdk,
}

### Managed resources
package { 'java':
ensure => $java::manage_package,
name => $java::real_package,
ensure => $manage_package,
name => $real_package,
}

if $java::bool_jdk == true {
if $bool_jdk == true {
package { 'java-jdk':
ensure => $java::manage_package,
name => $java::real_package_jdk,
ensure => $manage_package,
name => $real_package_jdk,
}
}

### Debugging, if enabled ( debug => true )
if $java::bool_debug == true {
if $bool_debug == true {
file { 'debug_java':
ensure => $java::manage_file,
ensure => $manage_file,
path => "${settings::vardir}/debug-java",
mode => '0640',
owner => 'root',
Expand All @@ -92,5 +98,4 @@
if $java::my_class {
include $java::my_class
}

}
26 changes: 11 additions & 15 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# Installation method ('package' or 'source'). Default 'package'.
#
# [*install_source*]
# Source URL (when install='source'). Not default.
# Source URL (when install='source'). Default: ''
#
# [*package*]
# Name of the package to install (when install='package'). If not default it's
Expand Down Expand Up @@ -58,14 +58,13 @@

case $install {

package: {

'package': {
$headless_suffix = $bool_headless ? {
true => '-headless',
default => '',
}
$real_package = $package ? {
'' => $bool_jdk ? {
'' => $bool_jdk ? {
false => $::operatingsystem ? {
/(?i:RedHat|Centos|Fedora|Scientific|Amazon|Linux)/ => "java-1.${version}.0-openjdk",
/(?i:Ubuntu|Debian|Mint)/ => "openjdk-${version}-jre${headless_suffix}",
Expand All @@ -74,21 +73,21 @@
/(?i:Solaris)/ => $::operatingsystemmajrelease ? {
'10' => "CSWjre${version}",
'11' => "jre-${version}",
'5' => undef,
'5' => '',
},
default => fail("OperatingSystem ${::operatingsystem} not supported"),
},
true => $::operatingsystem ? {
true => $::operatingsystem ? {
/(?i:RedHat|Centos|Fedora|Scientific|Amazon|Linux)/ => "java-1.${version}.0-openjdk-devel",
/(?i:Ubuntu|Debian|Mint)/ => "openjdk-${version}-jdk",
/(?i:SLES)/ => "java-1_${version}_0-ibm",
/(?i:OpenSuSE)/ => "java-1_${version}_0-openjdk-devel",
/(?i:Solaris)/ => $::operatingsystemmajrelease ? {
'10' => "CSWjdk${version}",
'11' => "jdk-${version}",
'5' => "jdk",
'5' => 'jdk',
},
default => fail("OperatingSystem ${::operatingsystem} not supported"),
default => fail("OperatingSystem ${::operatingsystem} not supported"),
}
},
default => $package,
Expand All @@ -105,10 +104,8 @@
responsefile => $package_responsefile,
provider => $package_provider,
}

}

source: {
'source': {
if (!$install_source) {
fail('Required arguement: install_source')
}
Expand All @@ -130,10 +127,9 @@
target => $created_dir,
require => Puppi::Netinstall["netinstall_java_${name}"],
}

}

default: { }

default: {
fail("java::install::${name}::install is <${install}> and must be 'package' or 'source'.")
}
}
}
7 changes: 0 additions & 7 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,9 @@
default => '/usr/lib/jvm',
}


# Real package names are computed in java class
$package = ''
$package_jdk = ''

# General Settings
$my_class = ''
$absent = false
$puppi = false
$puppi_helper = 'standard'
$debug = false

}
Loading