From de05057e1d240dc7e68f79eefa15a628fcaca3b8 Mon Sep 17 00:00:00 2001 From: Bryan Jen Date: Thu, 15 Oct 2015 09:37:37 -0700 Subject: [PATCH 1/7] update fixtures.yml to use git instead of http --- .fixtures.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.fixtures.yml b/.fixtures.yml index 5144894..ab2d177 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -1,5 +1,5 @@ fixtures: repositories: - stdlib: http://github.com/puppetlabs/puppetlabs-stdlib.git + stdlib: 'git://github.com/puppetlabs/puppetlabs-stdlib.git' symlinks: java: "#{source_dir}" From ca2171043ee2f73c5e43c8adf59e72b52c91ebe2 Mon Sep 17 00:00:00 2001 From: Oliver Chick Date: Wed, 18 Nov 2015 23:52:17 +0000 Subject: [PATCH 2/7] Add support for Ubuntu 15.10 --- manifests/params.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/params.pp b/manifests/params.pp index 985a62c..efe096b 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -108,7 +108,7 @@ class java::params { }, } } - 'vivid': { + 'vivid', 'wily': { $java = { 'jdk' => { 'package' => 'openjdk-8-jdk', From 9c154890a363be10a9ba6e09630f3c69008d670b Mon Sep 17 00:00:00 2001 From: Fabien Wernli Date: Tue, 5 May 2015 15:17:39 +0200 Subject: [PATCH 3/7] add two facts: java_libjvm_path java_default_home * dirname containing base directory of java * e.g. java binary is `${::java_default_home}/jre/bin/java` * dirname containing `libjvm.so` * Most people will use this for LD_LIBRARY_PATH --- README.markdown | 2 ++ lib/facter/java_default_home.rb | 21 ++++++++++++++++ lib/facter/java_libjvm_path.rb | 25 +++++++++++++++++++ spec/unit/facter/java_default_home_spec.rb | 29 ++++++++++++++++++++++ spec/unit/facter/java_libjvm_path_spec.rb | 21 ++++++++++++++++ 5 files changed, 98 insertions(+) create mode 100644 lib/facter/java_default_home.rb create mode 100644 lib/facter/java_libjvm_path.rb create mode 100644 spec/unit/facter/java_default_home_spec.rb create mode 100644 spec/unit/facter/java_libjvm_path_spec.rb diff --git a/README.markdown b/README.markdown index 5442157..369f896 100644 --- a/README.markdown +++ b/README.markdown @@ -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. diff --git a/lib/facter/java_default_home.rb b/lib/facter/java_default_home.rb new file mode 100644 index 0000000..3584b19 --- /dev/null +++ b/lib/facter/java_default_home.rb @@ -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 diff --git a/lib/facter/java_libjvm_path.rb b/lib/facter/java_libjvm_path.rb new file mode 100644 index 0000000..14fd78c --- /dev/null +++ b/lib/facter/java_libjvm_path.rb @@ -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 + diff --git a/spec/unit/facter/java_default_home_spec.rb b/spec/unit/facter/java_default_home_spec.rb new file mode 100644 index 0000000..32ebed9 --- /dev/null +++ b/spec/unit/facter/java_default_home_spec.rb @@ -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 diff --git a/spec/unit/facter/java_libjvm_path_spec.rb b/spec/unit/facter/java_libjvm_path_spec.rb new file mode 100644 index 0000000..ded1a4f --- /dev/null +++ b/spec/unit/facter/java_libjvm_path_spec.rb @@ -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 From 3a7ed12d494c0f20d37e84ba6d53102ff0be3100 Mon Sep 17 00:00:00 2001 From: thomas odukogbe Date: Mon, 21 Dec 2015 11:14:52 +0000 Subject: [PATCH 4/7] Added support for oracle-j2re1.8 and oracle-j2sdk1.8 --- manifests/params.pp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/manifests/params.pp b/manifests/params.pp index efe096b..a4a71c3 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -106,6 +106,18 @@ 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', 'wily': { From f1f2b830a0e07f6dc336fe0a2abc15560278e551 Mon Sep 17 00:00:00 2001 From: Peter Souter Date: Tue, 22 Dec 2015 01:13:14 +0000 Subject: [PATCH 5/7] (MODULES-2928) Adds FreeBSD Support * Note this won't work by default on FreeBSD Puppet < 4.0, as pkgng is not the default provider * On older Puppet, use `zleslie/pkgng`, on newer it's the default package provider. --- README.markdown | 10 ++++++++++ manifests/params.pp | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/README.markdown b/README.markdown index 369f896..ee2f6ef 100644 --- a/README.markdown +++ b/README.markdown @@ -116,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 can’t 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) diff --git a/manifests/params.pp b/manifests/params.pp index efe096b..b6b807a 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -133,6 +133,12 @@ class java::params { 'jre' => { 'package' => 'jre', }, } } + 'FreeBSD': { + $java = { + 'jdk' => { 'package' => 'openjdk', }, + 'jre' => { 'package' => 'openjdk-jre', }, + } + } 'Solaris': { $java = { 'jdk' => { 'package' => 'developer/java/jdk-7', }, From 3b8bba05ca6bd2e0378a707845da298a198a1631 Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Mon, 25 Jan 2016 16:01:58 +0000 Subject: [PATCH 6/7] (FM-4049) Update to current msync configs [2c99161] --- .gitignore | 1 + .rspec | 2 ++ .sync.yml | 7 ------- .travis.yml | 19 +++++++------------ CONTRIBUTING.md | 6 +++--- Gemfile | 22 +++++++++++----------- Rakefile | 3 ++- spec/spec_helper.rb | 7 ++++--- 8 files changed, 30 insertions(+), 37 deletions(-) create mode 100644 .rspec delete mode 100644 .sync.yml diff --git a/.gitignore b/.gitignore index b5db85e..3190277 100644 --- a/.gitignore +++ b/.gitignore @@ -5,5 +5,6 @@ spec/fixtures/ .vagrant/ .bundle/ coverage/ +log/ .idea/ *.iml diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..16f9cdb --- /dev/null +++ b/.rspec @@ -0,0 +1,2 @@ +--color +--format documentation diff --git a/.sync.yml b/.sync.yml deleted file mode 100644 index 3dd0ca0..0000000 --- a/.sync.yml +++ /dev/null @@ -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" diff --git a/.travis.yml b/.travis.yml index 7e8ed57..e6314a4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f1cbde4..bfeaa70 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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), diff --git a/Gemfile b/Gemfile index bfe64b1..ced190e 100644 --- a/Gemfile +++ b/Gemfile @@ -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 diff --git a/Rakefile b/Rakefile index 181157e..35ce311 100644 --- a/Rakefile +++ b/Rakefile @@ -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') diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 145dcf5..a7f5b4e 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -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 From 3842d6f6574fbcb9f67387b3d03953d9bfcd1be4 Mon Sep 17 00:00:00 2001 From: Benjamin Merot Date: Wed, 9 Dec 2015 12:01:15 +0100 Subject: [PATCH 7/7] Added possibility to pass options to package Exposed the Puppet 'package' resource's 'install_options' parameter via a new class parameter names 'package_options*. It takes an array of strings to pass installation options to the package provider of the targer OS (yum, apt-get, ...) Added validation of $package_options array Using stdlib' validate_array function to ensure that $package_options is a valid array (also if just empty). Cleaned array validation line Made $package_options undef by default Class parameter $package_options is now set to undef by default, validation is done in the class to ensure only an array would be passed to it if set. Added case for 'package_options' parameter Will test the use of the 'package_options' parameter being passed the YUM option --downloadonly which will see YUM return 0 but package will not be installed on system. Simplified test of 'package_options' parameter As the test 'select openjdk for Fedora 21 without installing' expects with a successful YUM run but the 'java' package not present, specifying package version is irrelevant. New case for complete installation with YUM option Added new case using 'package_options' with a a YUM option expected to not prevent rpm installation. Also added distribution parameter for test of 'pacakge_options' with yum option expected to prevent package installation. Removed validation of package name Removed validation of package name as it is not meant to be testing by 'select passed value for Fedora 21 with yum option' Removed test with '--downloadonly' The test of 'package_options* with the YUM option '---downloadonly' can't seem to be validate in CI. Other test 'select passed value for Fedora 21 with yum option' covers passing a value to 'package_options* and passes test in CI. --- manifests/init.pp | 14 ++++++++++++-- spec/classes/java_spec.rb | 7 +++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 19d3d79..d40b0f8 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -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': } diff --git a/spec/classes/java_spec.rb b/spec/classes/java_spec.rb index d44bedb..d58d442 100644 --- a/spec/classes/java_spec.rb +++ b/spec/classes/java_spec.rb @@ -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'} }