Merge branch 'master' into allow-tildes-in-version

This commit is contained in:
Joe Ray
2016-02-05 15:23:03 +00:00
16 changed files with 176 additions and 40 deletions

1
.gitignore vendored
View File

@@ -5,5 +5,6 @@ spec/fixtures/
.vagrant/
.bundle/
coverage/
log/
.idea/
*.iml

2
.rspec Normal file
View File

@@ -0,0 +1,2 @@
--color
--format documentation

View File

@@ -1,7 +0,0 @@
---
.travis.yml:
extras:
- rvm: 1.8.7
env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0"
- rvm: 1.8.7
env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0"

View File

@@ -1,24 +1,19 @@
---
sudo: false
language: ruby
cache: bundler
bundler_args: --without system_tests
script: "bundle exec rake validate && bundle exec rake lint && bundle exec rake spec SPEC_OPTS='--format documentation'"
script: "bundle exec rake validate lint spec"
matrix:
fast_finish: true
include:
- rvm: 1.8.7
- rvm: 2.1.6
env: PUPPET_GEM_VERSION="~> 4.0" STRICT_VARIABLES="yes"
- rvm: 2.1.5
env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes"
- rvm: 2.1.5
env: PUPPET_GEM_VERSION="~> 3.0"
- rvm: 1.9.3
env: PUPPET_GEM_VERSION="~> 3.0"
- rvm: 2.1.5
env: PUPPET_GEM_VERSION="~> 3.0"
- rvm: 2.1.5
env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes"
- rvm: 2.1.6
env: PUPPET_GEM_VERSION="~> 4.0" STRICT_VARIABLES="yes"
- rvm: 1.8.7
env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0"
- rvm: 1.8.7
env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0"
notifications:
email: false

View File

@@ -159,7 +159,7 @@ If you already have those gems installed, make sure they are up-to-date:
With all dependencies in place and up-to-date we can now run the tests:
```shell
% rake spec
% bundle exec rake spec
```
This will execute all the [rspec tests](http://rspec-puppet.com/) tests
@@ -178,8 +178,8 @@ installed on your system.
You can run them by issuing the following command
```shell
% rake spec_clean
% rspec spec/acceptance
% bundle exec rake spec_clean
% bundle exec rspec spec/acceptance
```
This will now download a pre-fabricated image configured in the [default node-set](./spec/acceptance/nodesets/default.yml),

22
Gemfile
View File

@@ -1,7 +1,7 @@
source ENV['GEM_SOURCE'] || "https://rubygems.org"
def location_for(place, fake_version = nil)
if place =~ /^(git:[^#]*)#(.*)/
if place =~ /^(git[:@][^#]*)#(.*)/
[fake_version, { :git => $1, :branch => $2, :require => false }].compact
elsif place =~ /^file:\/\/(.*)/
['>= 0', { :path => File.expand_path($1), :require => false }]
@@ -11,14 +11,16 @@ def location_for(place, fake_version = nil)
end
group :development, :unit_tests do
gem 'rspec-core', '3.1.7', :require => false
gem 'puppetlabs_spec_helper', :require => false
gem 'simplecov', :require => false
gem 'puppet_facts', :require => false
gem 'json', :require => false
gem 'json', :require => false
gem 'metadata-json-lint', :require => false
gem 'puppet_facts', :require => false
gem 'puppet-blacksmith', :require => false
gem 'puppetlabs_spec_helper', :require => false
gem 'rspec-puppet', '>= 2.3.2', :require => false
gem 'simplecov', :require => false
end
group :system_tests do
gem 'beaker-puppet_install_helper', :require => false
if beaker_version = ENV['BEAKER_VERSION']
gem 'beaker', *location_for(beaker_version)
end
@@ -27,12 +29,10 @@ group :system_tests do
else
gem 'beaker-rspec', :require => false
end
gem 'serverspec', :require => false
gem 'beaker-puppet_install_helper', :require => false
gem 'master_manipulator', :require => false
gem 'serverspec', :require => false
end
if facterversion = ENV['FACTER_GEM_VERSION']
gem 'facter', facterversion, :require => false
else

View File

@@ -79,6 +79,8 @@ The java module includes a few facts to describe the version of Java installed o
* `java_major_version`: The major version of Java.
* `java_patch_level`: The patch level of Java.
* `java_version`: The full Java version string.
* `java_default_home`: The absolute path to the java system home directory (only available on Linux). For instance, the `java` executable's path would be `${::java_default_home}/jre/bin/java`. This is slightly different from the "standard" JAVA_HOME environment variable.
* `java_libjvm_path`: The absolute path to the directory containing the shared library `libjvm.so` (only available on Linux). Useful for setting `LD_LIBRARY_PATH` or configuring the dynamic linker.
**Note:** The facts return `nil` if Java is not installed on the system.
@@ -114,6 +116,16 @@ the binaries to a standard directory. Because of that, the path to this location
is hardcoded in the java_version fact. Whenever a Java upgrade to a newer
version/path will be done on OpenBSD, it has to be adapted there.
### A note to FreeBSD
By default on FreeBSD Puppet < 4.0, you will see an error as `pkgng` is not the default provider. To fix this, you can install the [zleslie/pkgng module](https://forge.puppetlabs.com/zleslie/pkgng) and set it as the default package provider like so:
```puppet
Package {
provider => 'pkgng',
}
On Puppet > 4.0 (ie. using the sysutils/puppet4 port), `pkgng` is included within Puppet and it's the default package provider.
##Development
Puppet Labs modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We cant access the huge number of platforms and myriad hardware, software, and deployment configurations that Puppet is intended to serve. We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things. For more information, see our [module contribution guide.](https://docs.puppetlabs.com/forge/contributing.html)

View File

@@ -1,5 +1,6 @@
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet_blacksmith/rake_tasks'
require 'puppet-lint/tasks/puppet-lint'
require 'puppetlabs_spec_helper/rake_tasks'
PuppetLint.configuration.fail_on_warnings = true
PuppetLint.configuration.send('relative')

View File

@@ -0,0 +1,21 @@
# Fact: java_default_home
#
# Purpose: get absolute path of java system home
#
# Resolution:
# Uses `readlink` to resolve the path of `/usr/bin/java` then returns subsubdir
#
# Caveats:
# Requires readlink
#
# Notes:
# None
Facter.add(:java_default_home) do
confine :kernel => 'Linux'
setcode do
if Facter::Util::Resolution.which('readlink')
java_bin = Facter::Util::Resolution.exec('readlink -e /usr/bin/java').strip
java_default_home = File.dirname(File.dirname(File.dirname(java_bin)))
end
end
end

View File

@@ -0,0 +1,25 @@
# Fact: java_libjvm_path
#
# Purpose: get path to libjvm.so
#
# Resolution:
# Lists file in java default home and searches for the file
#
# Caveats:
# Needs to list files recursively. Returns the first match
#
# Notes:
# None
Facter.add(:java_libjvm_path) do
confine :kernel => "Linux"
setcode do
java_default_home = Facter.value(:java_default_home)
java_libjvm_file = Dir.glob("#{java_default_home}/jre/lib/**/libjvm.so")
if java_libjvm_file.nil? || java_libjvm_file.empty?
nil
else
File.dirname(java_libjvm_file[0])
end
end
end

View File

@@ -18,6 +18,10 @@
# The name of the java package. This is configurable in case a non-standard
# java package is desired.
#
# [*package_options*]
# Array of strings to pass installation options to the 'package' Puppet resource.
# Options available depend on the 'package' provider for the target OS.
#
# [*java_alternative*]
# The name of the java alternative to use on Debian systems.
# "update-java-alternatives -l" will show which choices are available.
@@ -41,12 +45,17 @@ class java(
$distribution = 'jdk',
$version = 'present',
$package = undef,
$package_options = undef,
$java_alternative = undef,
$java_alternative_path = undef
) {
include java::params
validate_re($version, 'present|installed|latest|^[.+_0-9a-zA-Z:~-]+$')
if $package_options != undef {
validate_array($package_options)
}
if has_key($java::params::java, $distribution) {
$default_package_name = $java::params::java[$distribution]['package']
@@ -98,8 +107,9 @@ class java(
anchor { 'java::begin:': }
->
package { 'java':
ensure => $version,
name => $use_java_package_name,
ensure => $version,
install_options => $package_options,
name => $use_java_package_name,
}
->
class { 'java::config': }

View File

@@ -106,9 +106,21 @@ class java::params {
'alternative_path' => '/usr/lib/jvm/j2sdk1.7-oracle/jre/bin/java',
'java_home' => '/usr/lib/jvm/j2sdk1.7-oracle/jre/',
},
'oracle-j2re' => {
'package' => 'oracle-j2re1.8',
'alternative' => 'j2re1.8-oracle',
'alternative_path' => '/usr/lib/jvm/j2re1.8-oracle/bin/java',
'java_home' => '/usr/lib/jvm/j2re1.8-oracle/',
},
'oracle-j2sdk' => {
'package' => 'oracle-j2sdk1.8',
'alternative' => 'j2sdk1.8-oracle',
'alternative_path' => '/usr/lib/jvm/j2sdk1.8-oracle/bin/java',
'java_home' => '/usr/lib/jvm/j2sdk1.8-oracle/',
},
}
}
'vivid': {
'vivid', 'wily': {
$java = {
'jdk' => {
'package' => 'openjdk-8-jdk',
@@ -133,6 +145,12 @@ class java::params {
'jre' => { 'package' => 'jre', },
}
}
'FreeBSD': {
$java = {
'jdk' => { 'package' => 'openjdk', },
'jre' => { 'package' => 'openjdk-jre', },
}
}
'Solaris': {
$java = {
'jdk' => { 'package' => 'developer/java/jdk-7', },

View File

@@ -47,6 +47,13 @@ describe 'java', :type => :class do
let(:params) { { 'distribution' => 'jre' } }
it { should contain_package('java').with_name('java-1.8.0-openjdk') }
end
context 'select passed value for Fedora 21 with yum option' do
let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Fedora', :operatingsystemrelease => '21'} }
let(:params) { { 'distribution' => 'jre' } }
let(:params) { { 'package_options' => ['--skip-broken'] } }
it { should contain_package('java') }
end
context 'select passed value for Centos 5.3' do
let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Centos', :operatingsystemrelease => '5.3'} }

View File

@@ -1,6 +1,7 @@
require 'puppetlabs_spec_helper/module_spec_helper'
RSpec.configure do |c|
# declare an exclusion filter for the tests using with_env on facter 1.6, as the function is not available on 1.6
c.filter_run_excluding :with_env => true if Facter.version =~ /^1\.6\./
# put local configuration and setup into spec_helper_local
begin
require 'spec_helper_local'
rescue LoadError
end

View File

@@ -0,0 +1,29 @@
require "spec_helper"
describe Facter::Util::Fact do
before {
Facter.clear
Facter.fact(:kernel).stubs(:value).returns('Linux')
}
describe "java_default_home" do
context 'returns java home path when readlink present' do
it do
java_path_output = <<-EOS
/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
EOS
Facter::Util::Resolution.expects(:which).with("readlink").returns(true)
Facter::Util::Resolution.expects(:exec).with("readlink -e /usr/bin/java").returns(java_path_output)
Facter.value(:java_default_home).should == "/usr/lib/jvm/java-7-openjdk-amd64"
end
end
context 'returns nil when readlink not present' do
it do
Facter::Util::Resolution.stubs(:exec)
Facter::Util::Resolution.expects(:which).with("readlink").at_least(1).returns(false)
Facter.value(:java_default_home).should be_nil
end
end
end
end

View File

@@ -0,0 +1,21 @@
require "spec_helper"
describe Facter::Util::Fact do
before {
Facter.clear
Facter.fact(:kernel).stubs(:value).returns('Linux')
java_default_home = '/usr/lib/jvm/java-8-openjdk-amd64'
Facter.fact(:java_default_home).stubs(:value).returns(java_default_home)
Dir.stubs(:glob).with("#{java_default_home}/jre/lib/**/libjvm.so").returns( ['/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server/libjvm.so'])
}
describe "java_libjvm_path" do
context 'returns libjvm path' do
context 'on Linux' do
it do
Facter.value(:java_libjvm_path).should == "/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server"
end
end
end
end
end