Compare commits

..

61 Commits
2.0.0 ... 2.1.1

Author SHA1 Message Date
Eric Putnam
336a0e2e1a Merge pull request #263 from pmcmaw/paulaTesting
(FM-6503) - Release Prep for 2.2.1
2017-11-08 09:25:50 -08:00
Paula McMaw
6592edd454 (FM-6503) - Release Prep for 2.2.1 2017-11-06 15:35:10 +00:00
Helen
e6e961e7fc Merge pull request #261 from bastelfreak/bumparchivebmjenplsmerge
allow latest archive version as dependency
2017-10-09 17:51:01 +01:00
Tim Meusel
2b2e639531 allow latest archive version as dependency 2017-10-09 18:30:09 +02:00
TP Honey
5f820fe8bd Merge pull request #257 from shuebnersr/fact1754_java_version_fails_when_JAVA_TOOL_OPTIONS_is_used
(FACT-1754) search for matching line with java version
2017-10-02 12:41:05 +01:00
shuebnersr
b7bdf96252 Fixed search for matching line with java version
Use value of variable instead of return statement
Extended unit test for checking handling of JAVA_TOOL_OPTIONS
2017-10-01 15:15:01 +02:00
TP Honey
231db77fe7 Merge pull request #203 from vrtdev/bugfix/override_package_alt_home
#MODULES-4069: Fail when required params are not available in params.
2017-09-26 14:02:45 +01:00
TP Honey
cb7105f4a2 Merge pull request #258 from shuebnersr/fact1760_test_for_java_version_when_java_not_installed
Fact1760 test for java version when java not installed
2017-09-26 14:00:12 +01:00
Jan Vansteenkiste
c40b061d97 (MODULES-4069) Fail when required params are not available in params.
When overriding all values required for the java setup, there is
no need to fail if params.pp does not support the package.
2017-09-26 07:37:41 +02:00
shuebnersr
18bd3fcb86 Merge pull request #2 from shuebnersr/fact1760_test_for_java_version_when_java_not_installed
Fact1760 test for java version when java not installed
2017-09-22 12:00:35 +02:00
shuebnersr
578eb951ea fix java_version test for other systems
mock Facter::Util::Resolution.which('java') for the "other systems" test; before it was not mocked and was based on Java being installed on the test system or not
2017-09-22 11:50:41 +02:00
shuebnersr
318f8864fd Merge pull request #1 from puppetlabs/master
sync
2017-09-22 11:39:28 +02:00
TP Honey
62f054649a Merge pull request #256 from puppetlabs/msync_18sep17_892c4cf
(maint) modulesync 892c4cf
2017-09-21 13:52:59 +01:00
shuebnersr
d89532435d search for matching line with java version
do not just try to read java version from first line, but search for the matching line from java output
2017-09-20 14:26:04 +02:00
Hailee Kenney
6397c0870b (maint) modulesync 892c4cf 2017-09-18 14:56:13 -07:00
Paula McMaw
e4888a507e Merge pull request #255 from Andor/master
Support for Ubuntu 17.04 Zesty Zapus
2017-09-08 11:41:23 +01:00
Andrew N Golovkov
525016ec02 Support for Ubuntu 17.04 Zesty Zapus 2017-09-06 20:44:48 +03:00
Helen
c5005d9cc1 Merge pull request #254 from pmcmaw/rm_debian6
Removing Debian 6
2017-08-31 11:30:33 +01:00
Paula McMaw
7f8bb518f0 Removing Debian 6
According to the followin page Debian 6 is no longer supported as an
Agent. https://docs.puppet.com/pe/latest/sys_req_os.html
2017-08-31 11:20:41 +01:00
TP Honey
771a3a6702 Merge pull request #253 from pmcmaw/rm_ubuntu
(MODULES-5501) - Remove unsupported Ubuntu
2017-08-17 16:00:54 +01:00
Paula McMaw
c74f533e0b (MODULES-5501) - Remove unsupported Ubuntu
Removing older version of Ubuntu that are not supported by the module.
2017-08-17 14:08:56 +01:00
Shaleen Gupta
43aa9af1b2 Add support for CloudLinux (#251)
Fix the fail "unsupported os CloudlLinux".
2017-08-01 13:30:38 +01:00
Paula McMaw
cceb78b7fe Merge pull request #252 from puppetlabs/maint-modsync-915cde70e20
(maint) modulesync 915cde70e20
2017-07-28 11:34:12 +01:00
Glenn Sarti
b50e762f1c (maint) modulesync 915cde70e20 2017-07-27 15:00:09 -07:00
Hunter Haugen
e9c50332bd Merge pull request #249 from puppetlabs/msync_modules5187
(MODULES-5187) msync puppet 5 and ruby 2.4
2017-07-10 14:51:42 -07:00
Eric Putnam
795b92a81d (MODULES-5187) mysnc puppet 5 and ruby 2.4 2017-07-06 14:41:47 -07:00
Glenn Sarti
31799ce4e7 Merge pull request #247 from hunner/bump_metadata
(MODULES-5144) Prep for puppet 5
2017-06-26 22:31:31 -07:00
Hunter Haugen
2829b75e83 (MODULES-5144) Prep for puppet 5 2017-06-26 14:12:02 -07:00
Bryan Jen
0ea0b663fa Merge pull request #246 from puppetlabs/release
2.1.0 mergeback
2017-06-22 16:30:00 -07:00
Glenn Sarti
e8808aca12 Merge pull request #245 from hunner/revert_3stuff
Revert "Release prep for 3.0.0"
2017-06-21 15:23:30 -07:00
Hunter Haugen
b410ac0882 Revert "Release prep for 3.0.0"
This reverts commit 15a208f3a5.
2017-06-21 15:16:31 -07:00
Hunter Haugen
6bbaacdb39 Merge pull request #244 from kBite/add-support-for-arch-linux
Add support for Archlinux
2017-06-21 14:29:25 -07:00
Kilian Engelhardt
6951263d4c fix indentation and remove a white line 2017-06-21 11:26:24 +02:00
Kilian Engelhardt
0bcdd2bc2f add basic arch linux support 2017-06-21 10:59:39 +02:00
Erick Banks
f80715ec6f Merge pull request #242 from hunner/add_url_hash_test
(maint) Add url_hash tests
2017-06-20 16:49:21 -07:00
Hunter Haugen
8458b03bb5 (maint) Add url_hash tests 2017-06-20 16:22:10 -07:00
Eric Putnam
ff33bcfa38 Merge pull request #240 from HelenCampbell/rpreppo
Release prep for 3.0.0
2017-06-15 16:03:40 -07:00
Helen Campbell
15a208f3a5 Release prep for 3.0.0 2017-06-15 17:14:13 +01:00
Paula McMaw
8763d0b388 Merge pull request #239 from puppetlabs/revert-238-release
Revert "Release Mergeback 2.1.0"
2017-06-15 11:20:16 +01:00
Helen
184c745e82 Revert "Release Mergeback 2.1.0" 2017-06-15 11:03:44 +01:00
Paula McMaw
9a209faa17 Merge pull request #238 from puppetlabs/release
Release Mergeback 2.1.0
2017-06-15 10:42:49 +01:00
Eric Putnam
b7085db8ae Merge pull request #237 from hunner/release_2.1.0
Release 2.1.0
2017-06-13 16:31:32 -07:00
Hunter Haugen
2c8b460b98 Release 2.1.0 2017-06-13 11:14:20 -07:00
Paula McMaw
a09bc3aa52 Merge pull request #236 from HelenCampbell/adddocsfix
MODULES-5047 - Update java::oracle class to work with new download URLs
2017-06-13 15:15:59 +01:00
Michael Watters
08423fb170 MODULES-5047 - Update java::oracle class to work with new download URLs
Oracle appears to have changed the JDK URL structure starting with Java 8u121.
This update adds a hash to store the values used by Oracle's java download site
along with a case statement to lookup the proper key for the java release being
installed.
2017-06-13 14:57:18 +01:00
Eric Putnam
da3e40903d Merge pull request #235 from hunner/fix_rhel7_home
(maint) Update java_home for redhat 7
2017-06-12 15:13:16 -07:00
Hunter Haugen
e234375924 (maint) Update java_home for redhat systems
It appears that redhat 7 and variants no longer have
java-1.7.0-openjdk-$arch symlinks. All redhat 6/7's both 32 and 64 bit
seem to include a java-1.7.0 symlink though.
2017-06-12 14:54:22 -07:00
Helen
73604a3419 Merge pull request #234 from spynappels/MODULES-5058
MODULES-5058 Allow a complete URL to be passed to the java::oracle class
2017-06-08 13:48:52 +01:00
Stefan Pijnappels
05b9d1c2ba MODULES-5058 Allow a complete URL to be passed to the java::oracle class
This provides a workaround  to the issue of Oracle changing it's URL structure which breaks the dynamic URL building in the module.
It allows a complete URL to be passed as an alternative to one built by the logic in the module, and allows the rest of the module to function as expected when this situation is encountered.

Changes made to manifests/oracle.pp to pass URL in `url` parameter (if defined) to the `source` directive of the archive resource which fetches the installer package.
README.markdown has been updated to document the additional parameter, as well as a note added to known issues describing it's operation.
A test has been added to spec/defines/oracle_spec.rb to verify the correct package is present in the tmp archive location. The spec tests have passed and the revised workflow has been tested in a lab environment and found to be working.
2017-06-08 10:29:58 +01:00
Hunter Haugen
49369bd48c Merge pull request #215 from vrtdev/bugfix/MODULES-4368-java_default_home-invalid-fact
See: https://tickets.puppetlabs.com/browse/MODULES-4368
2017-06-07 16:15:47 -07:00
Ben Ford
1af563c6d5 Merge pull request #223 from bastelfreak/puppet4
replace validate_* calls with datatypes & minor fixes
2017-06-07 15:02:15 -07:00
Tim Meusel
cf14116641 add datatypes for all parameters 2017-06-07 23:28:06 +02:00
Tim Meusel
3dacc7abe5 fix markdown linter warnings 2017-06-07 20:59:06 +02:00
Tim Meusel
66662bf4e9 replace validate_* calls with datatypes 2017-06-07 11:17:11 +02:00
Tim Meusel
585bd5795e bump stdlib to recommended puppet4 version 2017-06-07 11:17:08 +02:00
Tim Meusel
4f7d760f10 use proper syntax highlighting in markdown 2017-06-07 11:16:07 +02:00
Tim Meusel
920748cf0a purge trailing whitespace 2017-06-07 11:16:06 +02:00
Tim Meusel
75939fffc9 fix headlines in markdown 2017-06-07 11:15:37 +02:00
Glenn Sarti
de802e57bd Merge branch 'release'
* release:
  (maint) facts update oracle.pp
  (maint) update metadata
  fixed formatting errors + made various minor changes
  (MODULES-4958) prep for 2.0.0 release and some markdown rendering fixes
2017-05-30 16:27:35 -07:00
Jan Vansteenkiste
c0227ce820 MODULES-4368: return nil if java_bin is not found (readlink result is empty) 2017-02-01 08:10:59 +01:00
Jan Vansteenkiste
20960ddb7f MODULES-4368: Add a test case for the issue 2017-02-01 08:10:15 +01:00
17 changed files with 442 additions and 195 deletions

View File

@@ -22,10 +22,10 @@ matrix:
script: bundle exec rake beaker script: bundle exec rake beaker
services: docker services: docker
sudo: required sudo: required
- rvm: 2.3.1 - rvm: 2.4.0
bundler_args: --without system_tests bundler_args: --without system_tests
env: PUPPET_GEM_VERSION="~> 4.0" env: PUPPET_GEM_VERSION="~> 5.0"
- rvm: 2.1.7 - rvm: 2.1.9
bundler_args: --without system_tests bundler_args: --without system_tests
env: PUPPET_GEM_VERSION="~> 4.0" env: PUPPET_GEM_VERSION="~> 4.0"
notifications: notifications:

View File

@@ -1,3 +1,32 @@
## Supported Release 2.1.1
### Summary
This release is a maintenance release that includes a roll up of minor changes.
#### Added
- Basic Arch Linux, Cloud Linux and Ubuntu 17.04 compatibility.
- Metadata bump for Puppet 5.
- Search for matching line with java version.
- ([MODULES-4069](https://tickets.puppet.com/browse/MODULES-4069)) Fail when required params are not available in params.
- A test for java version when java not installed.
- Allow latest archive version as dependency.
#### Changed
- CONTRIBUTING.md document includes updates.
- Removal of Ubuntu 10.04 ad 12.04, Debian 6 in supported versions.
## Supported Release 2.1.0
### Summary
This release adds fixes to restore the ability to install Oracle Java. It also fixes the paths for the latest RHEL 7 1.7.0 and 1.8.0 OpenJDKs.
### Added
- java::oracle parameter `url`
- java::oracle parameter `url_hash`
### Fixed
- Let `java_default_home` fact work when /usr/bin/java does not exist
- Add puppet 4 parameter types
- Use `/usr/lib/jvm/java-1.x.0` symlinks for `java_home` defaults.
## Supported Release 2.0.0 ## Supported Release 2.0.0
### Summary ### Summary
@@ -113,7 +142,7 @@ This release adds 3 new facts for determining Java version, adds RHEL alternativ
## 2014-11-11 - Supported Version 1.2.0 ## 2014-11-11 - Supported Version 1.2.0
### Summary: ### Summary:
This release adds SLES 12 support and is tested for Future Parser Support This release adds SLES 12 support and is tested for Future Parser Support
#### Bugfixes: #### Bugfixes:
@@ -127,7 +156,7 @@ This release adds SLES 12 support and is tested for Future Parser Support
## 2014-08-25 - Supported Version 1.1.2 ## 2014-08-25 - Supported Version 1.1.2
### Summary: ### Summary:
This release begins the support coverage of the puppetlabs-java module. This release begins the support coverage of the puppetlabs-java module.
### Bugfixes: ### Bugfixes:
@@ -200,11 +229,11 @@ Scott Schneider <sschneider@puppetlabs.com>
* Add Solaris support * Add Solaris support
## 2011-06-16 - Version 0.1.5 ## 2011-06-16 - Version 0.1.5
Jeff McCune <jeff@puppetlabs.com> Jeff McCune <jeff@puppetlabs.com>
* Add Debian based distro (Lucid) support * Add Debian based distro (Lucid) support
## 2011-06-02 - Version 0.1.4 ## 2011-06-02 - Version 0.1.4
Jeff McCune <jeff@puppetlabs.com> Jeff McCune <jeff@puppetlabs.com>
* Fix class composition ordering problems * Fix class composition ordering problems
## 2011-05-28 - Version 0.1.3 ## 2011-05-28 - Version 0.1.3
@@ -221,9 +250,9 @@ Jeff McCune <jeff@puppetlabs.com>
* Add validation of class parameters * Add validation of class parameters
## 2011-05-24 - Version 0.1.0 ## 2011-05-24 - Version 0.1.0
Jeff McCune <jeff@puppetlabs.com> Jeff McCune <jeff@puppetlabs.com>
* Default to JDK version 6u25 * Default to JDK version 6u25
## 2011-05-24 - Version 0.0.1 ## 2011-05-24 - Version 0.0.1
Jeff McCune <jeff@puppetlabs.com> Jeff McCune <jeff@puppetlabs.com>
* Initial release * Initial release

View File

@@ -1,63 +1,75 @@
Checklist (and a short version for the impatient) # Contributing to Puppet modules
=================================================
* Commits: So you want to contribute to a Puppet module: Great! Below are some instructions to get you started doing
that very thing while setting expectations around code quality as well as a few tips for making the
process as easy as possible.
- Make commits of logical units. ### Table of Contents
- Check for unnecessary whitespace with "git diff --check" before 1. [Getting Started](#getting-started)
committing. 1. [Commit Checklist](#commit-checklist)
1. [Submission](#submission)
1. [More about commits](#more-about-commits)
1. [Testing](#testing)
- [Running Tests](#running-tests)
- [Writing Tests](#writing-tests)
1. [Get Help](#get-help)
- Commit using Unix line endings (check the settings around "crlf" in ## Getting Started
git-config(1)).
- Do not check in commented out code or unneeded files. - Fork the module repository on GitHub and clone to your workspace
- The first line of the commit message should be a short - Make your changes!
description (50 characters is the soft limit, excluding ticket
number(s)), and should skip the full stop.
- Associate the issue in the message. The first line should include ## Commit Checklist
the issue number in the form "(#XXXX) Rest of message".
- The body should provide a meaningful commit message, which: ### The Basics
- uses the imperative, present tense: "change", not "changed" or - [x] my commit is a single logical unit of work
"changes".
- includes motivation for the change, and contrasts its - [x] I have checked for unnecessary whitespace with "git diff --check"
implementation with the previous behavior.
- Make sure that you have tests for the bug you are fixing, or - [x] my commit does not include commented out code or unneeded files
feature you are adding.
- Make sure the test suites passes after your commit: ### The Content
`bundle exec rspec spec/acceptance` More information on [testing](#Testing) below
- When introducing a new feature, make sure it is properly - [x] my commit includes tests for the bug I fixed or feature I added
documented in the README.md
* Submission: - [x] my commit includes appropriate documentation changes if it is introducing a new feature or changing existing functionality
- [x] my code passes existing test suites
* Pre-requisites: ### The Commit Message
- Make sure you have a [GitHub account](https://github.com/join) - [x] the first line of my commit message includes:
- [Create a ticket](https://tickets.puppet.com/secure/CreateIssue!default.jspa), or [watch the ticket](https://tickets.puppet.com/browse/) you are patching for. - [x] an issue number (if applicable), e.g. "(MODULES-xxxx) This is the first line"
- [x] a short description (50 characters is the soft limit, excluding ticket number(s))
* Preferred method: - [x] the body of my commit message:
- Fork the repository on GitHub. - [x] is meaningful
- Push your changes to a topic branch in your fork of the - [x] uses the imperative, present tense: "change", not "changed" or "changes"
repository. (the format ticket/1234-short_description_of_change is
usually preferred for this project).
- Submit a pull request to the repository in the puppetlabs - [x] includes motivation for the change, and contrasts its implementation with the previous behavior
organization.
The long version ## Submission
================
### Pre-requisites
- Make sure you have a [GitHub account](https://github.com/join)
- [Create a ticket](https://tickets.puppet.com/secure/CreateIssue!default.jspa), or [watch the ticket](https://tickets.puppet.com/browse/) you are patching for.
### Push and PR
- Push your changes to your fork
- [Open a Pull Request](https://help.github.com/articles/creating-a-pull-request-from-a-fork/) against the repository in the puppetlabs organization
## More about commits
1. Make separate commits for logically separate changes. 1. Make separate commits for logically separate changes.
@@ -104,37 +116,32 @@ The long version
GitHub has some pretty good GitHub has some pretty good
[general documentation](http://help.github.com/) on using [general documentation](http://help.github.com/) on using
their site. They also have documentation on their site. They also have documentation on
[creating pull requests](http://help.github.com/send-pull-requests/). [creating pull requests](https://help.github.com/articles/creating-a-pull-request-from-a-fork/).
In general, after pushing your topic branch up to your In general, after pushing your topic branch up to your
repository on GitHub, you can switch to the branch in the repository on GitHub, you can switch to the branch in the
GitHub UI and click "Pull Request" towards the top of the page GitHub UI and click "Pull Request" towards the top of the page
in order to open a pull request. in order to open a pull request.
3. Update the related JIRA issue.
3. Update the related GitHub issue. If there is a JIRA issue associated with the change you
If there is a GitHub issue associated with the change you
submitted, then you should update the ticket to include the submitted, then you should update the ticket to include the
location of your branch, along with any other commentary you location of your branch, along with any other commentary you
may wish to make. may wish to make.
Testing # Testing
=======
Getting Started ## Getting Started
---------------
Our puppet modules provide [`Gemfile`](./Gemfile)s which can tell a ruby Our Puppet modules provide [`Gemfile`](./Gemfile)s, which can tell a Ruby package manager such as [bundler](http://bundler.io/) what Ruby packages,
package manager such as [bundler](http://bundler.io/) what Ruby packages,
or Gems, are required to build, develop, and test this software. or Gems, are required to build, develop, and test this software.
Please make sure you have [bundler installed](http://bundler.io/#getting-started) Please make sure you have [bundler installed](http://bundler.io/#getting-started) on your system, and then use it to
on your system, then use it to install all dependencies needed for this project, install all dependencies needed for this project in the project root by running
by running
```shell ```shell
% bundle install % bundle install --path .bundle/gems
Fetching gem metadata from https://rubygems.org/........ Fetching gem metadata from https://rubygems.org/........
Fetching gem metadata from https://rubygems.org/.. Fetching gem metadata from https://rubygems.org/..
Using rake (10.1.0) Using rake (10.1.0)
@@ -148,7 +155,7 @@ Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed. Use `bundle show [gemname]` to see where a bundled gem is installed.
``` ```
NOTE some systems may require you to run this command with sudo. NOTE: some systems may require you to run this command with sudo.
If you already have those gems installed, make sure they are up-to-date: If you already have those gems installed, make sure they are up-to-date:
@@ -156,26 +163,27 @@ If you already have those gems installed, make sure they are up-to-date:
% bundle update % bundle update
``` ```
With all dependencies in place and up-to-date we can now run the tests: ## Running Tests
With all dependencies in place and up-to-date, run the tests:
### Unit Tests
```shell ```shell
% bundle exec rake spec % bundle exec rake spec
``` ```
This will execute all the [rspec tests](http://rspec-puppet.com/) tests This executes all the [rspec tests](http://rspec-puppet.com/) in the directories defined [here](https://github.com/puppetlabs/puppetlabs_spec_helper/blob/699d9fbca1d2489bff1736bb254bb7b7edb32c74/lib/puppetlabs_spec_helper/rake_tasks.rb#L17) and so on.
under [spec/defines](./spec/defines), [spec/classes](./spec/classes), rspec tests may have the same kind of dependencies as the module they are testing. Although the module defines these dependencies in its [metadata.json](./metadata.json),
and so on. rspec tests may have the same kind of dependencies as the
module they are testing. While the module defines in its [Modulefile](./Modulefile),
rspec tests define them in [.fixtures.yml](./fixtures.yml). rspec tests define them in [.fixtures.yml](./fixtures.yml).
Some puppet modules also come with [beaker](https://github.com/puppetlabs/beaker) ### Acceptance Tests
tests. These tests spin up a virtual machine under
[VirtualBox](https://www.virtualbox.org/)) with, controlling it with
[Vagrant](http://www.vagrantup.com/) to actually simulate scripted test
scenarios. In order to run these, you will need both of those tools
installed on your system.
You can run them by issuing the following command Some Puppet modules also come with acceptance tests, which use [beaker][]. These tests spin up a virtual machine under
[VirtualBox](https://www.virtualbox.org/), controlled with [Vagrant](http://www.vagrantup.com/), to simulate scripted test
scenarios. In order to run these, you need both Virtualbox and Vagrant installed on your system.
Run the tests by issuing the following command
```shell ```shell
% bundle exec rake spec_clean % bundle exec rake spec_clean
@@ -183,35 +191,81 @@ You can run them by issuing the following command
``` ```
This will now download a pre-fabricated image configured in the [default node-set](./spec/acceptance/nodesets/default.yml), This will now download a pre-fabricated image configured in the [default node-set](./spec/acceptance/nodesets/default.yml),
install puppet, copy this module and install its dependencies per [spec/spec_helper_acceptance.rb](./spec/spec_helper_acceptance.rb) install Puppet, copy this module, and install its dependencies per [spec/spec_helper_acceptance.rb](./spec/spec_helper_acceptance.rb)
and then run all the tests under [spec/acceptance](./spec/acceptance). and then run all the tests under [spec/acceptance](./spec/acceptance).
Writing Tests ## Writing Tests
-------------
XXX getting started writing tests. ### Unit Tests
If you have commit access to the repository When writing unit tests for Puppet, [rspec-puppet][] is your best friend. It provides tons of helper methods for testing your manifests against a
=========================================== catalog (e.g. contain_file, contain_package, with_params, etc). It would be ridiculous to try and top rspec-puppet's [documentation][rspec-puppet_docs]
but here's a tiny sample:
Even if you have commit access to the repository, you will still need to Sample manifest:
go through the process above, and have someone else review and merge
in your changes. The rule is that all changes must be reviewed by a
developer on the project (that did not write the code) to ensure that
all changes go through a code review process.
Having someone other than the author of the topic branch recorded as ```puppet
performing the merge is the record that they performed the code file { "a test file":
review. ensure => present,
path => "/etc/sample",
}
```
Sample test:
Additional Resources ```ruby
==================== it 'does a thing' do
expect(subject).to contain_file("a test file").with({:path => "/etc/sample"})
end
```
* [Getting additional help](http://puppet.com/community/get-help) ### Acceptance Tests
Writing acceptance tests for Puppet involves [beaker][] and its cousin [beaker-rspec][]. A common pattern for acceptance tests is to create a test manifest, apply it
twice to check for idempotency or errors, then run expectations.
```ruby
it 'does an end-to-end thing' do
pp = <<-EOF
file { 'a test file':
ensure => present,
path => "/etc/sample",
content => "test string",
}
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end
describe file("/etc/sample") do
it { is_expected.to contain "test string" }
end
```
# If you have commit access to the repository
Even if you have commit access to the repository, you still need to go through the process above, and have someone else review and merge
in your changes. The rule is that **all changes must be reviewed by a project developer that did not write the code to ensure that
all changes go through a code review process.**
The record of someone performing the merge is the record that they performed the code review. Again, this should be someone other than the author of the topic branch.
# Get Help
### On the web
* [Puppet help messageboard](http://puppet.com/community/get-help)
* [Writing tests](https://docs.puppet.com/guides/module_guides/bgtm.html#step-three-module-testing) * [Writing tests](https://docs.puppet.com/guides/module_guides/bgtm.html#step-three-module-testing)
* [General GitHub documentation](http://help.github.com/) * [General GitHub documentation](http://help.github.com/)
* [GitHub pull request documentation](http://help.github.com/send-pull-requests/) * [GitHub pull request documentation](http://help.github.com/send-pull-requests/)
### On chat
* Slack (slack.puppet.com) #forge-modules, #puppet-dev, #windows, #voxpupuli
* IRC (freenode) #puppet-dev, #voxpupuli
[rspec-puppet]: http://rspec-puppet.com/
[rspec-puppet_docs]: http://rspec-puppet.com/documentation/
[beaker]: https://github.com/puppetlabs/beaker
[beaker-rspec]: https://github.com/puppetlabs/beaker-rspec

15
Gemfile
View File

@@ -33,13 +33,13 @@ ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments
minor_version = "#{ruby_version_segments[0]}.#{ruby_version_segments[1]}" minor_version = "#{ruby_version_segments[0]}.#{ruby_version_segments[1]}"
group :development do group :development do
gem "puppet-module-posix-default-r#{minor_version}", :require => false, :platforms => "ruby" gem "puppet-module-posix-default-r#{minor_version}", :require => false, :platforms => "ruby"
gem "puppet-module-win-default-r#{minor_version}", :require => false, :platforms => ["mswin", "mingw", "x64_mingw"] gem "puppet-module-win-default-r#{minor_version}", :require => false, :platforms => ["mswin", "mingw", "x64_mingw"]
gem "puppet-module-posix-dev-r#{minor_version}", :require => false, :platforms => "ruby" gem "puppet-module-posix-dev-r#{minor_version}", :require => false, :platforms => "ruby"
gem "puppet-module-win-dev-r#{minor_version}", :require => false, :platforms => ["mswin", "mingw", "x64_mingw"] gem "puppet-module-win-dev-r#{minor_version}", '0.0.7', :require => false, :platforms => ["mswin", "mingw", "x64_mingw"]
gem "json_pure", '<= 2.0.1', :require => false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0') gem "json_pure", '<= 2.0.1', :require => false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0')
gem "fast_gettext", '1.1.0', :require => false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0') gem "fast_gettext", '1.1.0', :require => false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0')
gem "fast_gettext", :require => false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0') gem "fast_gettext", :require => false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0')
end end
group :system_tests do group :system_tests do
@@ -50,6 +50,7 @@ group :system_tests do
gem "beaker-rspec", *location_for(ENV['BEAKER_RSPEC_VERSION']) gem "beaker-rspec", *location_for(ENV['BEAKER_RSPEC_VERSION'])
gem "beaker-hostgenerator", *location_for(ENV['BEAKER_HOSTGENERATOR_VERSION']) gem "beaker-hostgenerator", *location_for(ENV['BEAKER_HOSTGENERATOR_VERSION'])
gem "beaker-abs", *location_for(ENV['BEAKER_ABS_VERSION'] || '~> 0.1') gem "beaker-abs", *location_for(ENV['BEAKER_ABS_VERSION'] || '~> 0.1')
gem "puppet-blacksmith", '~> 3.4', :require => false
end end
gem 'puppet', *location_for(ENV['PUPPET_GEM_VERSION']) gem 'puppet', *location_for(ENV['PUPPET_GEM_VERSION'])

View File

@@ -13,7 +13,7 @@
## Overview ## Overview
Installs the correct Java package on various platforms. Installs the correct Java package on various platforms.
## Module Description ## Module Description
@@ -22,29 +22,30 @@ The java module can automatically install Java jdk or jre on a wide variety of s
## Setup ## Setup
### Beginning with the java module ### Beginning with the java module
To install the correct Java package on your system, include the `java` class: `include java`. To install the correct Java package on your system, include the `java` class: `include java`.
## Usage ## Usage
The java module installs the correct jdk or jre package on a wide variety of systems. By default, the module installs the jdk package, but you can set different installation parameters as needed. For example, to install jre instead of jdk, you would set the distribution parameter: The java module installs the correct jdk or jre package on a wide variety of systems. By default, the module installs the jdk package, but you can set different installation parameters as needed. For example, to install jre instead of jdk, you would set the distribution parameter:
~~~ ```puppet
class { 'java': class { 'java':
distribution => 'jre', distribution => 'jre',
} }
~~~ ```
To install the latest patch version of Java 8 on CentOS To install the latest patch version of Java 8 on CentOS
~~~ ```puppet
class { 'java' : class { 'java' :
package => 'java-1.8.0-openjdk-devel', package => 'java-1.8.0-openjdk-devel',
} }
~~~ ```
The defined type `java::oracle` installs one or more versions of Oracle Java SE. `java::oracle` depends on [puppet/archive](https://github.com/voxpupuli/puppet-archive). By using `java::oracle` you agree to Oracle's licensing terms for Java SE. The defined type `java::oracle` installs one or more versions of Oracle Java SE. `java::oracle` depends on [puppet/archive](https://github.com/voxpupuli/puppet-archive). By using `java::oracle` you agree to Oracle's licensing terms for Java SE.
~~~ ```puppet
java::oracle { 'jdk6' : java::oracle { 'jdk6' :
ensure => 'present', ensure => 'present',
version => '6', version => '6',
@@ -56,18 +57,18 @@ java::oracle { 'jdk8' :
version => '8', version => '8',
java_se => 'jdk', java_se => 'jdk',
} }
~~~ ```
To install a specific release of a Java version, e.g. 8u101-b13, provide both parameters `version_major` and `version_minor` as follows: To install a specific release of a Java version, e.g. 8u101-b13, provide both parameters `version_major` and `version_minor` as follows:
~~~ ```puppet
java::oracle { 'jdk8' : java::oracle { 'jdk8' :
ensure => 'present', ensure => 'present',
version_major => '8u101', version_major => '8u101',
version_minor => 'b13', version_minor => 'b13',
java_se => 'jdk', java_se => 'jdk',
} }
~~~ ```
## Reference ## Reference
@@ -85,26 +86,32 @@ java::oracle { 'jdk8' :
#### Parameters #### Parameters
The following parameters are available in `java`: The following parameters are available in `java`:
##### `distribution` ##### `distribution`
Specifies the Java distribution to install.
Specifies the Java distribution to install.
Valid options: 'jdk', 'jre', or, where the platform supports alternative packages, 'sun-jdk', 'sun-jre', 'oracle-jdk', 'oracle-jre'. Default: 'jdk'. Valid options: 'jdk', 'jre', or, where the platform supports alternative packages, 'sun-jdk', 'sun-jre', 'oracle-jdk', 'oracle-jre'. Default: 'jdk'.
##### `java_alternative` ##### `java_alternative`
Specifies the name of the Java alternative to use. If you set this parameter, *you must also set the `java_alternative_path`.*
Specifies the name of the Java alternative to use. If you set this parameter, *you must also set the `java_alternative_path`.*
Valid options: Run command `update-java-alternatives -l` for a list of available choices. Default: OS and distribution dependent defaults on *deb systems, undef on others. Valid options: Run command `update-java-alternatives -l` for a list of available choices. Default: OS and distribution dependent defaults on *deb systems, undef on others.
##### `java_alternative_path` ##### `java_alternative_path`
*Required when `java_alternative` is specified.* Defines the path to the `java` command.
*Required when `java_alternative` is specified.* Defines the path to the `java` command.
Valid option: String. Default: OS and distribution dependent defaults on *deb systems, undef on others. Valid option: String. Default: OS and distribution dependent defaults on *deb systems, undef on others.
##### `package` ##### `package`
Specifies the name of the Java package. This is configurable in case you want to install a non-standard Java package. If not set, the module installs the appropriate package for the `distribution` parameter and target platform. If you set `package`, the `distribution` parameter does nothing.
Valid option: String. Default: undef. Specifies the name of the Java package. This is configurable in case you want to install a non-standard Java package. If not set, the module installs the appropriate package for the `distribution` parameter and target platform. If you set `package`, the `distribution` parameter does nothing.
Valid option: String. Default: undef.
##### `version` ##### `version`
Sets the version of Java to install, if you want to ensure a particular version.
Sets the version of Java to install, if you want to ensure a particular version.
Valid options: 'present', 'installed', 'latest', or a string matching `/^[.+_0-9a-zA-Z:-]+$/`. Default: 'present'. Valid options: 'present', 'installed', 'latest', or a string matching `/^[.+_0-9a-zA-Z:-]+$/`. Default: 'present'.
#### Public defined types #### Public defined types
@@ -119,26 +126,41 @@ The following parameters are available in `java::oracle`:
Version of Java Standard Edition (SE) to install. 6, 7 or 8. Version of Java Standard Edition (SE) to install. 6, 7 or 8.
##### `version_major` ##### `version_major`
Major version of the Java Standard Edition (SE) to install. Must be used together with `version_minor`. For example, '8u101'. Major version of the Java Standard Edition (SE) to install. Must be used together with `version_minor`. For example, '8u101'.
##### `version_minor` ##### `version_minor`
Minor version (or build version) of the Java Standard Edition (SE) to install. Must be used together with `version_major`. For example, 'b13'. Minor version (or build version) of the Java Standard Edition (SE) to install. Must be used together with `version_major`. For example, 'b13'.
##### `java_se` ##### `java_se`
Type of Java SE to install, jdk or jre. Type of Java SE to install, jdk or jre.
##### `ensure` ##### `ensure`
Install or remove the package. Install or remove the package.
##### `oracle_url` ##### `oracle_url`
Official Oracle URL to download the binaries from. Official Oracle URL to download the binaries from.
##### `proxy_server` ##### `proxy_server`
Specify a proxy server, with port number if needed. ie: https://example.com:8080. (passed to archive) Specify a proxy server, with port number if needed. ie: https://example.com:8080. (passed to archive)
##### `proxy_type` ##### `proxy_type`
Proxy server type (none|http|https|ftp). (passed to archive) Proxy server type (none|http|https|ftp). (passed to archive)
##### `url`
Pass an entire URL to download the installer from rather than building the complete URL from other parameters. This will allow the module to be used even if the URLs are changed by Oracle. If this parameter is used, matching `version_major` and `version_minor` parameters must also be passed to the class.
##### `url_hash`
Directory hash used by the download.oracle.com site. This value is a 32 character string which is part of the file URL returned by the JDK download site.
### Facts ### Facts
The java module includes a few facts to describe the version of Java installed on the system: The java module includes a few facts to describe the version of Java installed on the system:
@@ -153,7 +175,7 @@ The java module includes a few facts to describe the version of Java installed o
## Limitations ## Limitations
This module cannot guarantee installation of Java versions that are not available on platform repositories. This module cannot guarantee installation of Java versions that are not available on platform repositories.
This module only manages a singular installation of Java, meaning it is not possible to manage e.g. OpenJDK 7, Oracle Java 7 and Oracle Java 8 in parallel on the same system. This module only manages a singular installation of Java, meaning it is not possible to manage e.g. OpenJDK 7, Oracle Java 7 and Oracle Java 8 in parallel on the same system.
@@ -161,7 +183,7 @@ Oracle Java packages are not included in Debian 7 and Ubuntu 12.04/14.04 reposit
This module is officially [supported](https://forge.puppetlabs.com/supported) for the following Java versions and platforms: This module is officially [supported](https://forge.puppetlabs.com/supported) for the following Java versions and platforms:
OpenJDK is supported on: OpenJDK is supported on:
* Red Hat Enterprise Linux (RHEL) 5, 6, 7 * Red Hat Enterprise Linux (RHEL) 5, 6, 7
* CentOS 5, 6, 7 * CentOS 5, 6, 7
@@ -173,15 +195,18 @@ OpenJDK is supported on:
* SLES 11 SP1, SP2, SP3, SP4; SLES 12, SP1, SP2 * SLES 11 SP1, SP2, SP3, SP4; SLES 12, SP1, SP2
* OpenBSD 5.6, 5.7 * OpenBSD 5.6, 5.7
Sun Java is supported on: Sun Java is supported on:
* Debian 6 * Debian 6
Oracle Java is supported on: Oracle Java is supported on:
* CentOS 6 * CentOS 6
### Known issues ### Known issues
Where Oracle change the format of the URLs to different installer packages, the curl to fetch the package may fail with a HTTP/404 error. In this case, passing a full known good URL using the `url` parameter will allow the module to still be able to install specific versions of the JRE/JDK. Note the `version_major` and `version_minor` parameters must be passed and must match the version downloaded using the known URL in the `url` parameter.
#### OpenBSD #### OpenBSD
OpenBSD packages install Java JRE/JDK in a unique directory structure, not linking OpenBSD packages install Java JRE/JDK in a unique directory structure, not linking

View File

@@ -15,7 +15,9 @@ Facter.add(:java_default_home) do
setcode do setcode do
if Facter::Util::Resolution.which('readlink') if Facter::Util::Resolution.which('readlink')
java_bin = Facter::Util::Resolution.exec('readlink -e /usr/bin/java').strip java_bin = Facter::Util::Resolution.exec('readlink -e /usr/bin/java').strip
if java_bin =~ %r(/jre/) if java_bin.empty?
nil
elsif java_bin =~ %r(/jre/)
java_default_home = File.dirname(File.dirname(File.dirname(java_bin))) java_default_home = File.dirname(File.dirname(File.dirname(java_bin)))
else else
java_default_home = File.dirname(File.dirname(java_bin)) java_default_home = File.dirname(File.dirname(java_bin))

View File

@@ -22,9 +22,11 @@ Facter.add(:java_version) do
# positive matches, so this needs to be done manually in setcode. # positive matches, so this needs to be done manually in setcode.
setcode do setcode do
unless [ 'openbsd', 'darwin' ].include? Facter.value(:operatingsystem).downcase unless [ 'openbsd', 'darwin' ].include? Facter.value(:operatingsystem).downcase
version = nil
if Facter::Util::Resolution.which('java') if Facter::Util::Resolution.which('java')
Facter::Util::Resolution.exec('java -Xmx12m -version 2>&1').lines.first.split(/"/)[1].strip Facter::Util::Resolution.exec('java -Xmx12m -version 2>&1').lines.each { |line| version = $~[1] if /^.+ version \"(.+)\"$/ =~ line }
end end
version
end end
end end
end end
@@ -34,9 +36,11 @@ Facter.add(:java_version) do
has_weight 100 has_weight 100
setcode do setcode do
Facter::Util::Resolution.with_env("PATH" => '/usr/local/jdk-1.7.0/jre/bin:/usr/local/jre-1.7.0/bin') do Facter::Util::Resolution.with_env("PATH" => '/usr/local/jdk-1.7.0/jre/bin:/usr/local/jre-1.7.0/bin') do
version = nil
if Facter::Util::Resolution.which('java') if Facter::Util::Resolution.which('java')
Facter::Util::Resolution.exec('java -Xmx12m -version 2>&1').lines.first.split(/"/)[1].strip Facter::Util::Resolution.exec('java -Xmx12m -version 2>&1').lines.each { |line| version = $~[1] if /^.+ version \"(.+)\"$/ =~ line }
end end
version
end end
end end
end end
@@ -46,7 +50,9 @@ Facter.add(:java_version) do
has_weight 100 has_weight 100
setcode do setcode do
unless /Unable to find any JVMs matching version/ =~ Facter::Util::Resolution.exec('/usr/libexec/java_home --failfast 2>&1') unless /Unable to find any JVMs matching version/ =~ Facter::Util::Resolution.exec('/usr/libexec/java_home --failfast 2>&1')
Facter::Util::Resolution.exec('java -Xmx12m -version 2>&1').lines.first.split(/"/)[1].strip version = nil
Facter::Util::Resolution.exec('java -Xmx12m -version 2>&1').lines.each { |line| version = $~[1] if /^.+ version \"(.+)\"$/ =~ line }
version
end end
end end
end end

View File

@@ -22,4 +22,5 @@ gettext:
# Patterns for +Dir.glob+ used to find all files that might contain # Patterns for +Dir.glob+ used to find all files that might contain
# translatable content, relative to the project root directory # translatable content, relative to the project root directory
source_files: source_files:
- './lib/**/*.rb'

View File

@@ -62,6 +62,15 @@ class java::config ( ) {
} }
} }
} }
'Archlinux': {
if $java::use_java_home != undef {
file_line { 'java-home-environment':
path => '/etc/profile',
line => "JAVA_HOME=${$java::use_java_home}",
match => 'JAVA_HOME=',
}
}
}
default: { default: {
# Do nothing. # Do nothing.
} }

View File

@@ -9,7 +9,6 @@
# or other platform-specific options where there are multiple # or other platform-specific options where there are multiple
# implementations available (eg: OpenJDK vs Oracle JDK). # implementations available (eg: OpenJDK vs Oracle JDK).
# #
#
# [*version*] # [*version*]
# The version of java to install. By default, this module simply ensures # The version of java to install. By default, this module simply ensures
# that java is present, and does not require a specific version. # that java is present, and does not require a specific version.
@@ -36,8 +35,8 @@
# correct JVM is enabled. # correct JVM is enabled.
# #
# [*java_home*] # [*java_home*]
# The path to where the JRE is installed. This will be set as an # The path to where the JRE is installed. This will be set as an
# environment variable. # environment variable.
# #
# Actions: # Actions:
# #
@@ -46,29 +45,19 @@
# Sample Usage: # Sample Usage:
# #
class java( class java(
$distribution = 'jdk', String $distribution = 'jdk',
$version = 'present', Pattern[/present|installed|latest|^[.+_0-9a-zA-Z:~-]+$/] $version = 'present',
$package = undef, Optional[String] $package = undef,
$package_options = undef, Optional[Array] $package_options = undef,
$java_alternative = undef, Optional[String] $java_alternative = undef,
$java_alternative_path = undef, Optional[String] $java_alternative_path = undef,
$java_home = undef Optional[String] $java_home = undef
) { ) {
include java::params include ::java::params
validate_re($version, 'present|installed|latest|^[.+_0-9a-zA-Z:~-]+$') $default_package_name = has_key($java::params::java, $distribution) ? {
false => undef,
if $package_options != undef { default => $java::params::java[$distribution]['package'],
validate_array($package_options)
}
if has_key($java::params::java, $distribution) {
$default_package_name = $java::params::java[$distribution]['package']
$default_alternative = $java::params::java[$distribution]['alternative']
$default_alternative_path = $java::params::java[$distribution]['alternative_path']
$default_java_home = $java::params::java[$distribution]['java_home']
} else {
fail("Java distribution ${distribution} is not supported.")
} }
$use_java_package_name = $package ? { $use_java_package_name = $package ? {
@@ -76,12 +65,17 @@ class java(
default => $package, default => $package,
} }
## Weird logic........
## If $java_alternative is set, use that. ## If $java_alternative is set, use that.
## Elsif the DEFAULT package is being used, then use $default_alternative. ## Elsif the DEFAULT package is being used, then use $default_alternative.
## Else undef ## Else undef
$use_java_alternative = $java_alternative ? { $use_java_alternative = $java_alternative ? {
undef => $use_java_package_name ? { undef => $use_java_package_name ? {
$default_package_name => $default_alternative, $default_package_name => has_key($java::params::java, $distribution) ? {
default => $java::params::java[$distribution]['alternative'],
false => undef,
},
default => undef, default => undef,
}, },
default => $java_alternative, default => $java_alternative,
@@ -89,21 +83,38 @@ class java(
## Same logic as $java_alternative above. ## Same logic as $java_alternative above.
$use_java_alternative_path = $java_alternative_path ? { $use_java_alternative_path = $java_alternative_path ? {
undef => $use_java_package_name ? { undef => $use_java_package_name ? {
$default_package_name => $default_alternative_path, $default_package_name => has_key($java::params::java, $distribution) ? {
default => $java::params::java[$distribution]['alternative_path'],
false => undef,
},
default => undef, default => undef,
}, },
default => $java_alternative_path, default => $java_alternative_path,
} }
$use_java_home = $java_home ? { $use_java_home = $java_home ? {
undef => $use_java_package_name ? { undef => $use_java_package_name ? {
$default_package_name => $default_java_home, $default_package_name => has_key($java::params::java, $distribution) ? {
default => $java::params::java[$distribution]['java_home'],
false => undef,
},
default => undef, default => undef,
}, },
default => $java_home, default => $java_home,
} }
## This should only be required if we did not override all the information we need.
# One of the defaults is missing and its not intentional:
if ((
$use_java_package_name == undef or $use_java_alternative == undef or
$use_java_alternative_path == undef or $use_java_home == undef
) and (
! has_key($::java::params::java, $distribution)
)) {
fail("Java distribution ${distribution} is not supported. Missing default values.")
}
$jre_flag = $use_java_package_name ? { $jre_flag = $use_java_package_name ? {
/headless/ => '--jre-headless', /headless/ => '--jre-headless',
default => '--jre' default => '--jre'

View File

@@ -10,7 +10,7 @@
# the licensing terms. # the licensing terms.
# wget --no-cookies --no-check-certificate --header \ # wget --no-cookies --no-check-certificate --header \
# "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" \ # "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" \
# "http://download.oracle.com/otn-pub/java/jdk/8u25-b17/jre-8u25-linux-x64.tar.gz" # "http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz"
# #
# Parameters # Parameters
# [*version*] # [*version*]
@@ -80,7 +80,12 @@
# #
# [*url*] # [*url*]
# Full URL, including oracle_url, release_major, release_minor and package_name, to # Full URL, including oracle_url, release_major, release_minor and package_name, to
# download the Oracle java_se installer. # download the Oracle java_se installer. Originally present but not used, activated
# to workaround MODULES-5058
#
# [*url_hash*]
# Directory hash used by the download.oracle.com site. This value is a 32 character string
# which is part of the file URL returned by the JDK download site.
# #
# ### Author # ### Author
# mike@marseglia.org # mike@marseglia.org
@@ -94,6 +99,8 @@ define java::oracle (
$oracle_url = 'http://download.oracle.com/otn-pub/java/jdk/', $oracle_url = 'http://download.oracle.com/otn-pub/java/jdk/',
$proxy_server = undef, $proxy_server = undef,
$proxy_type = undef, $proxy_type = undef,
$url = undef,
$url_hash = undef,
) { ) {
# archive module is used to download the java package # archive module is used to download the java package
@@ -108,8 +115,11 @@ define java::oracle (
# determine Oracle Java major and minor version, and installation path # determine Oracle Java major and minor version, and installation path
if $version_major and $version_minor { if $version_major and $version_minor {
$release_major = $version_major $release_major = $version_major
$release_minor = $version_minor $release_minor = $version_minor
$release_hash = $url_hash
if $release_major =~ /(\d+)u(\d+)/ { if $release_major =~ /(\d+)u(\d+)/ {
$install_path = "${java_se}1.${1}.0_${2}" $install_path = "${java_se}1.${1}.0_${2}"
} else { } else {
@@ -122,21 +132,25 @@ define java::oracle (
$release_major = '6u45' $release_major = '6u45'
$release_minor = 'b06' $release_minor = 'b06'
$install_path = "${java_se}1.6.0_45" $install_path = "${java_se}1.6.0_45"
$release_hash = undef
} }
'7' : { '7' : {
$release_major = '7u80' $release_major = '7u80'
$release_minor = 'b15' $release_minor = 'b15'
$install_path = "${java_se}1.7.0_80" $install_path = "${java_se}1.7.0_80"
$release_hash = undef
} }
'8' : { '8' : {
$release_major = '8u51' $release_major = '8u131'
$release_minor = 'b16' $release_minor = 'b11'
$install_path = "${java_se}1.8.0_51" $install_path = "${java_se}1.8.0_131"
$release_hash = 'd54c1d3a095b4ff2b6607d096fa80163'
} }
default : { default : {
$release_major = '8u51' $release_major = '8u131'
$release_minor = 'b16' $release_minor = 'b11'
$install_path = "${java_se}1.8.0_51" $install_path = "${java_se}1.8.0_131"
$release_hash = 'd54c1d3a095b4ff2b6607d096fa80163'
} }
} }
} }
@@ -175,11 +189,11 @@ define java::oracle (
} }
# following are based on this example: # following are based on this example:
# http://download.oracle.com/otn/java/jdk/7u80-b15/jre-7u80-linux-i586.rpm # http://download.oracle.com/otn-pub/java/jdk/7u80-b15/jre-7u80-linux-i586.rpm
# #
# JaveSE 6 distributed in .bin format # JaveSE 6 distributed in .bin format
# http://download.oracle.com/otn/java/jdk/6u45-b06/jdk-6u45-linux-i586-rpm.bin # http://download.oracle.com/otn-pub/java/jdk/6u45-b06/jdk-6u45-linux-i586-rpm.bin
# http://download.oracle.com/otn/java/jdk/6u45-b06/jdk-6u45-linux-i586.bin # http://download.oracle.com/otn-pub/java/jdk/6u45-b06/jdk-6u45-linux-i586.bin
# package name to download from Oracle's website # package name to download from Oracle's website
case $package_type { case $package_type {
'bin' : { 'bin' : {
@@ -196,6 +210,17 @@ define java::oracle (
} }
} }
# if complete URL is provided, use this value for source in archive resource
if $url {
$source = $url
}
elsif $release_hash != undef {
$source = "${oracle_url}/${release_major}-${release_minor}/${release_hash}/${package_name}"
}
else {
$source = "${oracle_url}/${release_major}-${release_minor}/${package_name}"
}
# full path to the installer # full path to the installer
$destination = "${destination_dir}${package_name}" $destination = "${destination_dir}${package_name}"
notice ("Destination is ${destination}") notice ("Destination is ${destination}")
@@ -219,7 +244,7 @@ define java::oracle (
'present' : { 'present' : {
archive { $destination : archive { $destination :
ensure => present, ensure => present,
source => "${oracle_url}${release_major}-${release_minor}/${package_name}", source => $source,
cookie => 'gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie', cookie => 'gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie',
extract_path => '/tmp', extract_path => '/tmp',
cleanup => false, cleanup => false,

View File

@@ -15,26 +15,28 @@ class java::params {
case $::osfamily { case $::osfamily {
'RedHat': { 'RedHat': {
case $::operatingsystem { case $::operatingsystem {
'RedHat', 'CentOS', 'OracleLinux', 'Scientific', 'OEL', 'SLC': { 'RedHat', 'CentOS', 'OracleLinux', 'Scientific', 'OEL', 'SLC', 'CloudLinux': {
if (versioncmp($::operatingsystemrelease, '5.0') < 0) { if (versioncmp($::operatingsystemrelease, '5.0') < 0) {
$jdk_package = 'java-1.6.0-sun-devel' $jdk_package = 'java-1.6.0-sun-devel'
$jre_package = 'java-1.6.0-sun' $jre_package = 'java-1.6.0-sun'
$java_home = '/usr/lib/jvm/java-1.6.0-sun/jre/' $java_home = '/usr/lib/jvm/java-1.6.0-sun/jre/'
} }
# See cde7046 for why >= 5.0 < 6.3
elsif (versioncmp($::operatingsystemrelease, '6.3') < 0) { elsif (versioncmp($::operatingsystemrelease, '6.3') < 0) {
$jdk_package = 'java-1.6.0-openjdk-devel' $jdk_package = 'java-1.6.0-openjdk-devel'
$jre_package = 'java-1.6.0-openjdk' $jre_package = 'java-1.6.0-openjdk'
$java_home = "/usr/lib/jvm/java-1.6.0-openjdk-${::architecture}/" $java_home = '/usr/lib/jvm/java-1.6.0/'
} }
# See PR#160 / c8e46b5 for why >= 6.3 < 7.1
elsif (versioncmp($::operatingsystemrelease, '7.1') < 0) { elsif (versioncmp($::operatingsystemrelease, '7.1') < 0) {
$jdk_package = 'java-1.7.0-openjdk-devel' $jdk_package = 'java-1.7.0-openjdk-devel'
$jre_package = 'java-1.7.0-openjdk' $jre_package = 'java-1.7.0-openjdk'
$java_home = "/usr/lib/jvm/java-1.7.0-openjdk-${::architecture}/" $java_home = '/usr/lib/jvm/java-1.7.0/'
} }
else { else {
$jdk_package = 'java-1.8.0-openjdk-devel' $jdk_package = 'java-1.8.0-openjdk-devel'
$jre_package = 'java-1.8.0-openjdk' $jre_package = 'java-1.8.0-openjdk'
$java_home = "/usr/lib/jvm/java-1.8.0-openjdk-${::architecture}/" $java_home = '/usr/lib/jvm/java-1.8.0/'
} }
} }
'Fedora': { 'Fedora': {
@@ -153,7 +155,7 @@ class java::params {
}, },
} }
} }
'stretch', 'vivid', 'wily', 'xenial', 'yakkety': { 'stretch', 'vivid', 'wily', 'xenial', 'yakkety', 'zesty': {
$java = { $java = {
'jdk' => { 'jdk' => {
'package' => 'openjdk-8-jdk', 'package' => 'openjdk-8-jdk',
@@ -251,6 +253,21 @@ class java::params {
}, },
} }
} }
'Archlinux': {
$jdk_package = 'jdk8-openjdk'
$jre_package = 'jre8-openjdk'
$java_home = '/usr/lib/jvm/java-8-openjdk/jre/'
$java = {
'jdk' => {
'package' => $jdk_package,
'java_home' => $java_home,
},
'jre' => {
'package' => $jre_package,
'java_home' => $java_home,
},
}
}
default: { fail("unsupported platform ${::osfamily}") } default: { fail("unsupported platform ${::osfamily}") }
} }
} }

View File

@@ -1,6 +1,6 @@
{ {
"name": "puppetlabs-java", "name": "puppetlabs-java",
"version": "2.0.0", "version": "2.1.1",
"author": "puppetlabs", "author": "puppetlabs",
"summary": "Installs the correct Java package on various platforms.", "summary": "Installs the correct Java package on various platforms.",
"license": "Apache-2.0", "license": "Apache-2.0",
@@ -49,7 +49,6 @@
{ {
"operatingsystem": "Debian", "operatingsystem": "Debian",
"operatingsystemrelease": [ "operatingsystemrelease": [
"6",
"7", "7",
"8" "8"
] ]
@@ -57,8 +56,6 @@
{ {
"operatingsystem": "Ubuntu", "operatingsystem": "Ubuntu",
"operatingsystemrelease": [ "operatingsystemrelease": [
"10.04",
"12.04",
"14.04", "14.04",
"16.04" "16.04"
] ]
@@ -85,11 +82,17 @@
"requirements": [ "requirements": [
{ {
"name": "puppet", "name": "puppet",
"version_requirement": ">= 4.7.0 < 5.0.0" "version_requirement": ">= 4.7.0 < 6.0.0"
} }
], ],
"dependencies": [ "dependencies": [
{"name":"puppetlabs/stdlib","version_requirement":">= 2.4.0 < 5.0.0"}, {
{"name":"puppet/archive","version_requirement":">= 1.1.0 < 2.0.0"} "name":"puppetlabs/stdlib",
"version_requirement": ">= 4.13.1 < 5.0.0"
},
{
"name":"puppet/archive",
"version_requirement": ">= 1.1.0 < 3.0.0"
}
] ]
} }

View File

@@ -5,19 +5,19 @@ describe 'java', :type => :class do
context 'select openjdk for Centos 5.8' do context 'select openjdk for Centos 5.8' do
let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Centos', :operatingsystemrelease => '5.8', :architecture => 'x86_64'} } let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Centos', :operatingsystemrelease => '5.8', :architecture => 'x86_64'} }
it { is_expected.to contain_package('java').with_name('java-1.6.0-openjdk-devel') } it { is_expected.to contain_package('java').with_name('java-1.6.0-openjdk-devel') }
it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk-x86_64/') } it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.6.0/') }
end end
context 'select openjdk for Centos 6.3' do context 'select openjdk for Centos 6.3' do
let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Centos', :operatingsystemrelease => '6.3', :architecture => 'x86_64'} } let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Centos', :operatingsystemrelease => '6.3', :architecture => 'x86_64'} }
it { is_expected.to contain_package('java').with_name('java-1.7.0-openjdk-devel') } it { is_expected.to contain_package('java').with_name('java-1.7.0-openjdk-devel') }
it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-x86_64/') } it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.7.0/') }
end end
context 'select openjdk for Centos 7.1.1503' do context 'select openjdk for Centos 7.1.1503' do
let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Centos', :operatingsystemrelease => '7.1.1503', :architecture => 'x86_64'} } let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Centos', :operatingsystemrelease => '7.1.1503', :architecture => 'x86_64'} }
it { is_expected.to contain_package('java').with_name('java-1.8.0-openjdk-devel') } it { is_expected.to contain_package('java').with_name('java-1.8.0-openjdk-devel') }
it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-x86_64/') } it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.8.0/') }
end end
context 'select openjdk for Centos 6.2' do context 'select openjdk for Centos 6.2' do
@@ -193,14 +193,14 @@ describe 'java', :type => :class do
let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Scientific', :operatingsystemrelease => '6.4', :architecture => 'x86_64'} } let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Scientific', :operatingsystemrelease => '6.4', :architecture => 'x86_64'} }
let(:params) { { 'distribution' => 'jre' } } let(:params) { { 'distribution' => 'jre' } }
it { is_expected.to contain_package('java').with_name('java-1.7.0-openjdk') } it { is_expected.to contain_package('java').with_name('java-1.7.0-openjdk') }
it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-x86_64/') } it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.7.0/') }
end end
context 'select passed value for Scientific Linux CERN (SLC)' do context 'select passed value for Scientific Linux CERN (SLC)' do
let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'SLC', :operatingsystemrelease => '6.4', :architecture => 'x86_64'} } let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'SLC', :operatingsystemrelease => '6.4', :architecture => 'x86_64'} }
let(:params) { { 'distribution' => 'jre' } } let(:params) { { 'distribution' => 'jre' } }
it { is_expected.to contain_package('java').with_name('java-1.7.0-openjdk') } it { is_expected.to contain_package('java').with_name('java-1.7.0-openjdk') }
it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-x86_64/') } it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/lib/jvm/java-1.7.0/') }
end end
context 'select default for OpenSUSE 12.3' do context 'select default for OpenSUSE 12.3' do
@@ -245,6 +245,34 @@ describe 'java', :type => :class do
it { is_expected.to contain_package('java').with_name('jre') } it { is_expected.to contain_package('java').with_name('jre') }
end end
describe 'custom java package' do
let(:facts) { {:osfamily => 'Debian', :operatingsystem => 'Debian', :lsbdistcodename => 'jessie', :operatingsystemrelease => '8.6', :architecture => 'amd64',} }
context 'all params provided' do
let(:params) { {
'distribution' => 'custom',
'package' => 'custom_jdk',
'java_alternative' => 'java-custom_jdk',
'java_alternative_path' => '/opt/custom_jdk/bin/java',
'java_home' => '/opt/custom_jdk',
} }
it { is_expected.to contain_package('java').with_name('custom_jdk') }
it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/opt/custom_jdk') }
it { is_expected.to contain_exec('update-java-alternatives').with_command('update-java-alternatives --set java-custom_jdk --jre') }
end
context 'missing parameters' do
let(:params) { {
'distribution' => 'custom',
'package' => 'custom_jdk',
} }
it do
expect { catalogue }.to raise_error Puppet::Error, /is not supported. Missing default values/
end
end
end
describe 'incompatible OSs' do describe 'incompatible OSs' do
[ [
{ {

View File

@@ -23,9 +23,9 @@ describe 'java::oracle', :type => :define do
context 'Oracle Java SE 8 JDK' do context 'Oracle Java SE 8 JDK' do
let(:params) { {:ensure => 'present', :version => '8', :java_se => 'jdk'} } let(:params) { {:ensure => 'present', :version => '8', :java_se => 'jdk'} }
let :title do 'jdk8' end let :title do 'jdk8' end
it { is_expected.to contain_archive('/tmp/jdk-8u51-linux-x64.rpm')} it { is_expected.to contain_archive('/tmp/jdk-8u131-linux-x64.rpm')}
it { is_expected.to contain_exec('Install Oracle java_se jdk 8').with_command('rpm --force -iv /tmp/jdk-8u51-linux-x64.rpm') } it { is_expected.to contain_exec('Install Oracle java_se jdk 8').with_command('rpm --force -iv /tmp/jdk-8u131-linux-x64.rpm') }
it { is_expected.to contain_exec('Install Oracle java_se jdk 8').that_requires('Archive[/tmp/jdk-8u51-linux-x64.rpm]') } it { is_expected.to contain_exec('Install Oracle java_se jdk 8').that_requires('Archive[/tmp/jdk-8u131-linux-x64.rpm]') }
end end
context 'Oracle Java SE 6 JRE' do context 'Oracle Java SE 6 JRE' do
@@ -47,11 +47,35 @@ describe 'java::oracle', :type => :define do
context 'select Oracle Java SE 8 JRE' do context 'select Oracle Java SE 8 JRE' do
let(:params) { {:ensure => 'present', :version => '8', :java_se => 'jre'} } let(:params) { {:ensure => 'present', :version => '8', :java_se => 'jre'} }
let :title do 'jre8' end let :title do 'jre8' end
it { is_expected.to contain_archive('/tmp/jre-8u51-linux-x64.rpm')} it { is_expected.to contain_archive('/tmp/jre-8u131-linux-x64.rpm')}
it { is_expected.to contain_exec('Install Oracle java_se jre 8').with_command('rpm --force -iv /tmp/jre-8u51-linux-x64.rpm') } it { is_expected.to contain_exec('Install Oracle java_se jre 8').with_command('rpm --force -iv /tmp/jre-8u131-linux-x64.rpm') }
it { is_expected.to contain_exec('Install Oracle java_se jre 8').that_requires('Archive[/tmp/jre-8u51-linux-x64.rpm]') } it { is_expected.to contain_exec('Install Oracle java_se jre 8').that_requires('Archive[/tmp/jre-8u131-linux-x64.rpm]') }
end end
context 'Pass URL to url parameter' do
let(:params) { {
:ensure => 'present',
:version_major => '8u131',
:version_minor => 'b11',
:java_se => 'jdk',
:url => 'http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.rpm',
:url_hash => 'ignored',
} }
let :title do 'jdk8' end
it { is_expected.to contain_archive('/tmp/jdk-8u131-linux-x64.rpm').with_source('http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.rpm') }
end
context 'Pass a hash to url_hash parameter' do
let(:params) { {
:ensure => 'present',
:version_major => '8u131',
:version_minor => 'b11',
:java_se => 'jdk',
:url_hash => 'abcdef01234567890',
} }
let :title do 'jdk8' end
it { is_expected.to contain_archive('/tmp/jdk-8u131-linux-x64.rpm').with_source('http://download.oracle.com/otn-pub/java/jdk//8u131-b11/abcdef01234567890/jdk-8u131-linux-x64.rpm') }
end
end end
context 'On CentOS 32-bit' do context 'On CentOS 32-bit' do
@@ -76,9 +100,9 @@ describe 'java::oracle', :type => :define do
context 'select Oracle Java SE 8 JDK on RedHat family, 32-bit' do context 'select Oracle Java SE 8 JDK on RedHat family, 32-bit' do
let(:params) { {:ensure => 'present', :version => '8', :java_se => 'jdk'} } let(:params) { {:ensure => 'present', :version => '8', :java_se => 'jdk'} }
let :title do 'jdk8' end let :title do 'jdk8' end
it { is_expected.to contain_archive('/tmp/jdk-8u51-linux-i586.rpm')} it { is_expected.to contain_archive('/tmp/jdk-8u131-linux-i586.rpm')}
it { is_expected.to contain_exec('Install Oracle java_se jdk 8').with_command('rpm --force -iv /tmp/jdk-8u51-linux-i586.rpm') } it { is_expected.to contain_exec('Install Oracle java_se jdk 8').with_command('rpm --force -iv /tmp/jdk-8u131-linux-i586.rpm') }
it { is_expected.to contain_exec('Install Oracle java_se jdk 8').that_requires('Archive[/tmp/jdk-8u51-linux-i586.rpm]') } it { is_expected.to contain_exec('Install Oracle java_se jdk 8').that_requires('Archive[/tmp/jdk-8u131-linux-i586.rpm]') }
end end
context 'select Oracle Java SE 6 JRE on RedHat family, 32-bit' do context 'select Oracle Java SE 6 JRE on RedHat family, 32-bit' do
@@ -100,9 +124,9 @@ describe 'java::oracle', :type => :define do
context 'select Oracle Java SE 8 JRE on RedHat family, 32-bit' do context 'select Oracle Java SE 8 JRE on RedHat family, 32-bit' do
let(:params) { {:ensure => 'present', :version => '8', :java_se => 'jre'} } let(:params) { {:ensure => 'present', :version => '8', :java_se => 'jre'} }
let :title do 'jdk8' end let :title do 'jdk8' end
it { is_expected.to contain_archive('/tmp/jre-8u51-linux-i586.rpm')} it { is_expected.to contain_archive('/tmp/jre-8u131-linux-i586.rpm')}
it { is_expected.to contain_exec('Install Oracle java_se jre 8').with_command('rpm --force -iv /tmp/jre-8u51-linux-i586.rpm') } it { is_expected.to contain_exec('Install Oracle java_se jre 8').with_command('rpm --force -iv /tmp/jre-8u131-linux-i586.rpm') }
it { is_expected.to contain_exec('Install Oracle java_se jre 8').that_requires('Archive[/tmp/jre-8u51-linux-i586.rpm]') } it { is_expected.to contain_exec('Install Oracle java_se jre 8').that_requires('Archive[/tmp/jre-8u131-linux-i586.rpm]') }
end end
end end

View File

@@ -29,6 +29,14 @@ describe Facter::Util::Fact do
end end
end end
end end
context 'returns nil when readlink is present but java is not' do
it do
java_path_output = ""
Facter::Util::Resolution.expects(:which).with("readlink").returns(true)
Facter::Util::Resolution.expects(:exec).with("readlink -e /usr/bin/java").returns(java_path_output)
expect(Facter.value(:java_default_home)).to be_nil
end
end
context 'returns nil when readlink not present' do context 'returns nil when readlink not present' do
it do it do

View File

@@ -14,6 +14,7 @@ describe Facter::Util::Fact do
let(:facts) { {:operatingsystem => 'OpenBSD'} } let(:facts) { {:operatingsystem => 'OpenBSD'} }
it do it do
java_version_output = <<-EOS java_version_output = <<-EOS
Picked up JAVA_TOOL_OPTIONS: -Djava.net.preferIPv4Stack=true
openjdk version "1.7.0_71" openjdk version "1.7.0_71"
OpenJDK Runtime Environment (build 1.7.0_71-b14) OpenJDK Runtime Environment (build 1.7.0_71-b14)
OpenJDK 64-Bit Server VM (build 24.71-b01, mixed mode) OpenJDK 64-Bit Server VM (build 24.71-b01, mixed mode)
@@ -30,6 +31,7 @@ OpenJDK 64-Bit Server VM (build 24.71-b01, mixed mode)
let(:facts) { {:operatingsystem => 'Darwin'} } let(:facts) { {:operatingsystem => 'Darwin'} }
it do it do
java_version_output = <<-EOS java_version_output = <<-EOS
Picked up JAVA_TOOL_OPTIONS: -Djava.net.preferIPv4Stack=true
java version "1.7.0_71" java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14) Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode) Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)
@@ -46,10 +48,12 @@ Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)
let(:facts) { {:operatingsystem => 'MyOS'} } let(:facts) { {:operatingsystem => 'MyOS'} }
it do it do
java_version_output = <<-EOS java_version_output = <<-EOS
Picked up JAVA_TOOL_OPTIONS: -Djava.net.preferIPv4Stack=true
java version "1.7.0_71" java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14) Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode) Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)
EOS EOS
Facter::Util::Resolution.expects(:which).with("java").returns('/path/to/java')
Facter::Util::Resolution.expects(:exec).with("java -Xmx12m -version 2>&1").returns(java_version_output) Facter::Util::Resolution.expects(:exec).with("java -Xmx12m -version 2>&1").returns(java_version_output)
expect(Facter.value(:java_version)).to eq("1.7.0_71") expect(Facter.value(:java_version)).to eq("1.7.0_71")
end end