Compare commits
69 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
39113d885a | ||
|
|
d0c9b41d9d | ||
|
|
d336d79c04 | ||
|
|
e1df6498c7 | ||
|
|
e50eb64614 | ||
|
|
bdfc567c18 | ||
|
|
db30eb9e2d | ||
|
|
d49c1f0e29 | ||
|
|
336a0e2e1a | ||
|
|
6592edd454 | ||
|
|
e6e961e7fc | ||
|
|
2b2e639531 | ||
|
|
5f820fe8bd | ||
|
|
b7bdf96252 | ||
|
|
231db77fe7 | ||
|
|
cb7105f4a2 | ||
|
|
c40b061d97 | ||
|
|
18bd3fcb86 | ||
|
|
578eb951ea | ||
|
|
318f8864fd | ||
|
|
62f054649a | ||
|
|
d89532435d | ||
|
|
6397c0870b | ||
|
|
e4888a507e | ||
|
|
525016ec02 | ||
|
|
c5005d9cc1 | ||
|
|
7f8bb518f0 | ||
|
|
771a3a6702 | ||
|
|
c74f533e0b | ||
|
|
43aa9af1b2 | ||
|
|
cceb78b7fe | ||
|
|
b50e762f1c | ||
|
|
e9c50332bd | ||
|
|
795b92a81d | ||
|
|
31799ce4e7 | ||
|
|
2829b75e83 | ||
|
|
0ea0b663fa | ||
|
|
e8808aca12 | ||
|
|
b410ac0882 | ||
|
|
6bbaacdb39 | ||
|
|
6951263d4c | ||
|
|
0bcdd2bc2f | ||
|
|
f80715ec6f | ||
|
|
8458b03bb5 | ||
|
|
ff33bcfa38 | ||
|
|
15a208f3a5 | ||
|
|
8763d0b388 | ||
|
|
184c745e82 | ||
|
|
9a209faa17 | ||
|
|
b7085db8ae | ||
|
|
2c8b460b98 | ||
|
|
a09bc3aa52 | ||
|
|
08423fb170 | ||
|
|
da3e40903d | ||
|
|
e234375924 | ||
|
|
73604a3419 | ||
|
|
05b9d1c2ba | ||
|
|
49369bd48c | ||
|
|
1af563c6d5 | ||
|
|
cf14116641 | ||
|
|
3dacc7abe5 | ||
|
|
66662bf4e9 | ||
|
|
585bd5795e | ||
|
|
4f7d760f10 | ||
|
|
920748cf0a | ||
|
|
75939fffc9 | ||
|
|
de802e57bd | ||
|
|
c0227ce820 | ||
|
|
20960ddb7f |
@@ -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:
|
||||||
|
|||||||
55
CHANGELOG.md
55
CHANGELOG.md
@@ -1,3 +1,44 @@
|
|||||||
|
## Supported Release [2.2.0]
|
||||||
|
### Summary
|
||||||
|
This release is a maintenance release that includes a roll up of minor changes.
|
||||||
|
|
||||||
|
#### Added
|
||||||
|
- Addition of Ubuntu for Oracle Java.
|
||||||
|
- Addition of Debian 9 in supported versions.
|
||||||
|
- Addition of OpenBSD case and use `realpath` rather than `readlink` in Java Default Home Facter fact.
|
||||||
|
|
||||||
|
#### Removed
|
||||||
|
- Removal of OpenBSD as a special case and deprecated `with_env` in Java Version Facter Facter fact.
|
||||||
|
|
||||||
|
## 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 +154,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 +168,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 +241,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 +262,11 @@ 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
|
||||||
|
|
||||||
|
[2.2.0]:https://github.com/puppetlabs/puppetlabs-java/compare/2.1.1...2.2.0
|
||||||
222
CONTRIBUTING.md
222
CONTRIBUTING.md
@@ -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
15
Gemfile
@@ -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'])
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -3,22 +3,25 @@
|
|||||||
# Purpose: get absolute path of java system home
|
# Purpose: get absolute path of java system home
|
||||||
#
|
#
|
||||||
# Resolution:
|
# Resolution:
|
||||||
# Uses `readlink` to resolve the path of `/usr/bin/java` then returns subsubdir
|
# Find the real java binary, and return the subsubdir
|
||||||
#
|
#
|
||||||
# Caveats:
|
# Caveats:
|
||||||
# Requires readlink
|
# java binary has to be found in $PATH
|
||||||
#
|
#
|
||||||
# Notes:
|
# Notes:
|
||||||
# None
|
# None
|
||||||
Facter.add(:java_default_home) do
|
Facter.add(:java_default_home) do
|
||||||
confine :kernel => 'Linux'
|
confine :kernel => [ 'Linux', 'OpenBSD' ]
|
||||||
setcode do
|
setcode do
|
||||||
if Facter::Util::Resolution.which('readlink')
|
java_bin = Facter::Util::Resolution.which('java').to_s.strip
|
||||||
java_bin = Facter::Util::Resolution.exec('readlink -e /usr/bin/java').strip
|
if java_bin.empty?
|
||||||
if java_bin =~ %r(/jre/)
|
nil
|
||||||
java_default_home = File.dirname(File.dirname(File.dirname(java_bin)))
|
else
|
||||||
|
java_path = File.realpath(java_bin)
|
||||||
|
if java_path =~ %r(/jre/)
|
||||||
|
java_default_home = File.dirname(File.dirname(File.dirname(java_path)))
|
||||||
else
|
else
|
||||||
java_default_home = File.dirname(File.dirname(java_bin))
|
java_default_home = File.dirname(File.dirname(java_path))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
# Notes:
|
# Notes:
|
||||||
# None
|
# None
|
||||||
Facter.add(:java_libjvm_path) do
|
Facter.add(:java_libjvm_path) do
|
||||||
confine :kernel => "Linux"
|
confine :kernel => [ "Linux", "OpenBSD" ]
|
||||||
setcode do
|
setcode do
|
||||||
java_default_home = Facter.value(:java_default_home)
|
java_default_home = Facter.value(:java_default_home)
|
||||||
java_libjvm_file = Dir.glob("#{java_default_home}/jre/lib/**/libjvm.so")
|
java_libjvm_file = Dir.glob("#{java_default_home}/jre/lib/**/libjvm.so")
|
||||||
|
|||||||
@@ -21,22 +21,12 @@ Facter.add(:java_version) do
|
|||||||
# Additionally, facter versions prior to 2.0.1 only support
|
# Additionally, facter versions prior to 2.0.1 only support
|
||||||
# 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 [ '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
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
Facter.add(:java_version) do
|
|
||||||
confine :operatingsystem => 'OpenBSD'
|
|
||||||
has_weight 100
|
|
||||||
setcode do
|
|
||||||
Facter::Util::Resolution.with_env("PATH" => '/usr/local/jdk-1.7.0/jre/bin:/usr/local/jre-1.7.0/bin') do
|
|
||||||
if Facter::Util::Resolution.which('java')
|
|
||||||
Facter::Util::Resolution.exec('java -Xmx12m -version 2>&1').lines.first.split(/"/)[1].strip
|
|
||||||
end
|
end
|
||||||
|
version
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -46,7 +36,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
|
||||||
|
|||||||
@@ -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'
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class java::config ( ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
'OpenBSD', 'FreeBSD', 'Suse': {
|
'FreeBSD', 'Suse': {
|
||||||
if $java::use_java_home != undef {
|
if $java::use_java_home != undef {
|
||||||
file_line { 'java-home-environment':
|
file_line { 'java-home-environment':
|
||||||
path => '/etc/environment',
|
path => '/etc/environment',
|
||||||
@@ -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.
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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'
|
||||||
|
|||||||
@@ -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'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -152,6 +166,11 @@ define java::oracle (
|
|||||||
} else {
|
} else {
|
||||||
$package_type = 'rpm'
|
$package_type = 'rpm'
|
||||||
}
|
}
|
||||||
|
$creates_path = "/usr/java/${install_path}"
|
||||||
|
}
|
||||||
|
'Debian' : {
|
||||||
|
$package_type = 'tar.gz'
|
||||||
|
$creates_path = "/usr/lib/jvm/${install_path}"
|
||||||
}
|
}
|
||||||
default : {
|
default : {
|
||||||
fail ("unsupported platform ${$facts['os']['name']}") }
|
fail ("unsupported platform ${$facts['os']['name']}") }
|
||||||
@@ -159,7 +178,6 @@ define java::oracle (
|
|||||||
|
|
||||||
$os = 'linux'
|
$os = 'linux'
|
||||||
$destination_dir = '/tmp/'
|
$destination_dir = '/tmp/'
|
||||||
$creates_path = "/usr/java/${install_path}"
|
|
||||||
}
|
}
|
||||||
default : {
|
default : {
|
||||||
fail ( "unsupported platform ${$facts['kernel']}" ) }
|
fail ( "unsupported platform ${$facts['kernel']}" ) }
|
||||||
@@ -169,17 +187,18 @@ define java::oracle (
|
|||||||
case $facts['os']['architecture'] {
|
case $facts['os']['architecture'] {
|
||||||
'i386' : { $arch = 'i586' }
|
'i386' : { $arch = 'i586' }
|
||||||
'x86_64' : { $arch = 'x64' }
|
'x86_64' : { $arch = 'x64' }
|
||||||
|
'amd64' : { $arch = 'x64' }
|
||||||
default : {
|
default : {
|
||||||
fail ("unsupported platform ${$facts['os']['architecture']}")
|
fail ("unsupported platform ${$facts['os']['architecture']}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# 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' : {
|
||||||
@@ -191,11 +210,25 @@ define java::oracle (
|
|||||||
'rpm' : {
|
'rpm' : {
|
||||||
$package_name = "${java_se}-${release_major}-${os}-${arch}.rpm"
|
$package_name = "${java_se}-${release_major}-${os}-${arch}.rpm"
|
||||||
}
|
}
|
||||||
|
'tar.gz' : {
|
||||||
|
$package_name = "${java_se}-${release_major}-${os}-${arch}.tar.gz"
|
||||||
|
}
|
||||||
default : {
|
default : {
|
||||||
$package_name = "${java_se}-${release_major}-${os}-${arch}.rpm"
|
$package_name = "${java_se}-${release_major}-${os}-${arch}.rpm"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 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}")
|
||||||
@@ -210,6 +243,9 @@ define java::oracle (
|
|||||||
'rpm' : {
|
'rpm' : {
|
||||||
$install_command = "rpm --force -iv ${destination}"
|
$install_command = "rpm --force -iv ${destination}"
|
||||||
}
|
}
|
||||||
|
'tar.gz' : {
|
||||||
|
$install_command = "tar -zxf ${destination} -C /usr/lib/jvm"
|
||||||
|
}
|
||||||
default : {
|
default : {
|
||||||
$install_command = "rpm -iv ${destination}"
|
$install_command = "rpm -iv ${destination}"
|
||||||
}
|
}
|
||||||
@@ -219,7 +255,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,
|
||||||
@@ -235,6 +271,15 @@ define java::oracle (
|
|||||||
creates => $creates_path,
|
creates => $creates_path,
|
||||||
require => Archive[$destination]
|
require => Archive[$destination]
|
||||||
}
|
}
|
||||||
|
case $facts['os']['family'] {
|
||||||
|
'Debian' : {
|
||||||
|
file{'/usr/lib/jvm':
|
||||||
|
ensure => directory,
|
||||||
|
before => Exec["Install Oracle java_se ${java_se} ${version}"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default : { }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
default : {
|
default : {
|
||||||
fail ("unsupported platform ${$facts['kernel']}")
|
fail ("unsupported platform ${$facts['kernel']}")
|
||||||
|
|||||||
@@ -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}") }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "puppetlabs-java",
|
"name": "puppetlabs-java",
|
||||||
"version": "2.0.0",
|
"version": "2.2.0",
|
||||||
"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,16 +49,14 @@
|
|||||||
{
|
{
|
||||||
"operatingsystem": "Debian",
|
"operatingsystem": "Debian",
|
||||||
"operatingsystemrelease": [
|
"operatingsystemrelease": [
|
||||||
"6",
|
|
||||||
"7",
|
"7",
|
||||||
"8"
|
"8",
|
||||||
|
"9"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"operatingsystem": "Ubuntu",
|
"operatingsystem": "Ubuntu",
|
||||||
"operatingsystemrelease": [
|
"operatingsystemrelease": [
|
||||||
"10.04",
|
|
||||||
"12.04",
|
|
||||||
"14.04",
|
"14.04",
|
||||||
"16.04"
|
"16.04"
|
||||||
]
|
]
|
||||||
@@ -85,11 +83,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"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -236,7 +236,7 @@ describe 'java', :type => :class do
|
|||||||
context 'select jdk for OpenBSD' do
|
context 'select jdk for OpenBSD' do
|
||||||
let(:facts) { {:osfamily => 'OpenBSD', :architecture => 'x86_64'} }
|
let(:facts) { {:osfamily => 'OpenBSD', :architecture => 'x86_64'} }
|
||||||
it { is_expected.to contain_package('java').with_name('jdk') }
|
it { is_expected.to contain_package('java').with_name('jdk') }
|
||||||
it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/local/jdk/') }
|
it { is_expected.to_not contain_file_line('java-home-environment') }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'select jre for OpenBSD' do
|
context 'select jre for OpenBSD' 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
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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,12 +124,69 @@ 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
|
||||||
|
|
||||||
|
context 'On Ubuntu 64-bit' do
|
||||||
|
let(:facts) { {:kernel => 'Linux', :os => { :family => 'Debian', :architecture => 'amd64', :name => 'Ubuntu', :release => { :full => '16.04' } } } }
|
||||||
|
|
||||||
|
context 'Oracle Java SE 6 JDK' do
|
||||||
|
let(:params) { {:ensure => 'present', :version => '6', :java_se => 'jdk'} }
|
||||||
|
let :title do 'jdk6' end
|
||||||
|
it { is_expected.to contain_archive('/tmp/jdk-6u45-linux-x64.tar.gz')}
|
||||||
|
it { is_expected.to contain_exec('Install Oracle java_se jdk 6').with_command('tar -zxf /tmp/jdk-6u45-linux-x64.tar.gz -C /usr/lib/jvm') }
|
||||||
|
it { is_expected.to contain_exec('Install Oracle java_se jdk 6').that_requires('Archive[/tmp/jdk-6u45-linux-x64.tar.gz]') }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'Oracle Java SE 7 JDK' do
|
||||||
|
let(:params) { {:ensure => 'present', :version => '7', :java_se => 'jdk'} }
|
||||||
|
let :title do 'jdk7' end
|
||||||
|
it { is_expected.to contain_archive('/tmp/jdk-7u80-linux-x64.tar.gz')}
|
||||||
|
it { is_expected.to contain_exec('Install Oracle java_se jdk 7').with_command('tar -zxf /tmp/jdk-7u80-linux-x64.tar.gz -C /usr/lib/jvm') }
|
||||||
|
it { is_expected.to contain_exec('Install Oracle java_se jdk 7').that_requires('Archive[/tmp/jdk-7u80-linux-x64.tar.gz]') }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'Oracle Java SE 8 JDK' do
|
||||||
|
let(:params) { {:ensure => 'present', :version => '8', :java_se => 'jdk'} }
|
||||||
|
let :title do 'jdk8' end
|
||||||
|
it { is_expected.to contain_archive('/tmp/jdk-8u131-linux-x64.tar.gz')}
|
||||||
|
it { is_expected.to contain_exec('Install Oracle java_se jdk 8').with_command('tar -zxf /tmp/jdk-8u131-linux-x64.tar.gz -C /usr/lib/jvm') }
|
||||||
|
it { is_expected.to contain_exec('Install Oracle java_se jdk 8').that_requires('Archive[/tmp/jdk-8u131-linux-x64.tar.gz]') }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'Oracle Java SE 6 JRE' do
|
||||||
|
let(:params) { {:ensure => 'present', :version => '6', :java_se => 'jre'} }
|
||||||
|
let :title do 'jre6' end
|
||||||
|
it { is_expected.to contain_archive('/tmp/jre-6u45-linux-x64.tar.gz')}
|
||||||
|
it { is_expected.to contain_exec('Install Oracle java_se jre 6').with_command('tar -zxf /tmp/jre-6u45-linux-x64.tar.gz -C /usr/lib/jvm') }
|
||||||
|
it { is_expected.to contain_exec('Install Oracle java_se jre 6').that_requires('Archive[/tmp/jre-6u45-linux-x64.tar.gz]') }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'Oracle Java SE 7 JRE' do
|
||||||
|
let(:params) { {:ensure => 'present', :version => '7', :java_se => 'jre'} }
|
||||||
|
let :title do 'jre7' end
|
||||||
|
it { is_expected.to contain_archive('/tmp/jre-7u80-linux-x64.tar.gz')}
|
||||||
|
it { is_expected.to contain_exec('Install Oracle java_se jre 7').with_command('tar -zxf /tmp/jre-7u80-linux-x64.tar.gz -C /usr/lib/jvm') }
|
||||||
|
it { is_expected.to contain_exec('Install Oracle java_se jre 7').that_requires('Archive[/tmp/jre-7u80-linux-x64.tar.gz]') }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'select Oracle Java SE 8 JRE' do
|
||||||
|
let(:params) { {:ensure => 'present', :version => '8', :java_se => 'jre'} }
|
||||||
|
let :title do 'jre8' end
|
||||||
|
it { is_expected.to contain_archive('/tmp/jre-8u131-linux-x64.tar.gz')}
|
||||||
|
it { is_expected.to contain_exec('Install Oracle java_se jre 8').with_command('tar -zxf /tmp/jre-8u131-linux-x64.tar.gz -C /usr/lib/jvm') }
|
||||||
|
it { is_expected.to contain_exec('Install Oracle java_se jre 8').that_requires('Archive[/tmp/jre-8u131-linux-x64.tar.gz]') }
|
||||||
|
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.tar.gz'} }
|
||||||
|
let :title do 'jdk8' end
|
||||||
|
it { is_expected.to contain_archive('/tmp/jdk-8u131-linux-x64.tar.gz')}
|
||||||
|
end
|
||||||
|
end
|
||||||
describe 'incompatible OSes' do
|
describe 'incompatible OSes' do
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,39 +1,50 @@
|
|||||||
require "spec_helper"
|
require "spec_helper"
|
||||||
|
|
||||||
|
def unlink_and_delete(filename)
|
||||||
|
if File.symlink?(filename)
|
||||||
|
File.unlink(filename)
|
||||||
|
end
|
||||||
|
if File.exist?(filename)
|
||||||
|
File.delete(filename)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe Facter::Util::Fact do
|
describe Facter::Util::Fact do
|
||||||
before {
|
|
||||||
Facter.clear
|
|
||||||
Facter.fact(:kernel).stubs(:value).returns('Linux')
|
|
||||||
}
|
|
||||||
|
|
||||||
describe "java_default_home" do
|
describe "java_default_home" do
|
||||||
context 'returns java home path when readlink present' do
|
before(:each) {
|
||||||
context 'when java is in HOME/jre/bin/java' do
|
Facter.clear
|
||||||
|
Facter.fact(:kernel).stubs(:value).returns('Linux')
|
||||||
|
}
|
||||||
|
|
||||||
|
context 'returns java home path when java found in PATH' do
|
||||||
|
context "when java is in /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java" do
|
||||||
it do
|
it do
|
||||||
java_path_output = <<-EOS
|
unlink_and_delete('./java_test')
|
||||||
/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
|
File.symlink('/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java', './java_test')
|
||||||
EOS
|
Facter::Util::Resolution.expects(:which).with("java").returns("./java_test")
|
||||||
Facter::Util::Resolution.expects(:which).with("readlink").returns(true)
|
File.expects(:realpath).with('./java_test').returns('/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java')
|
||||||
Facter::Util::Resolution.expects(:exec).with("readlink -e /usr/bin/java").returns(java_path_output)
|
expect(Facter.value(:java_default_home)).to eql '/usr/lib/jvm/java-7-openjdk-amd64'
|
||||||
expect(Facter.value(:java_default_home)).to eql "/usr/lib/jvm/java-7-openjdk-amd64"
|
unlink_and_delete('./java_test')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
context 'when java is in HOME/bin/java' do
|
|
||||||
|
context "when java is in /usr/lib/jvm/oracle-java8-jre-amd64/bin/java" do
|
||||||
it do
|
it do
|
||||||
java_path_output = <<-EOS
|
unlink_and_delete('./java_test')
|
||||||
/usr/lib/jvm/oracle-java8-jre-amd64/bin/java
|
File.symlink('/usr/lib/jvm/oracle-java8-jre-amd64/bin/java', './java_test')
|
||||||
EOS
|
Facter::Util::Resolution.expects(:which).with("java").returns("./java_test")
|
||||||
Facter::Util::Resolution.expects(:which).with("readlink").returns(true)
|
File.expects(:realpath).with('./java_test').returns('/usr/lib/jvm/oracle-java8-jre-amd64/bin/java')
|
||||||
Facter::Util::Resolution.expects(:exec).with("readlink -e /usr/bin/java").returns(java_path_output)
|
expect(Facter.value(:java_default_home)).to eql '/usr/lib/jvm/oracle-java8-jre-amd64'
|
||||||
expect(Facter.value(:java_default_home)).to eql "/usr/lib/jvm/oracle-java8-jre-amd64"
|
unlink_and_delete('./java_test')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'returns nil when readlink not present' do
|
context 'returns nil when java not present' do
|
||||||
it do
|
it do
|
||||||
Facter::Util::Resolution.stubs(:exec)
|
Facter::Util::Resolution.stubs(:exec)
|
||||||
Facter::Util::Resolution.expects(:which).with("readlink").at_least(1).returns(false)
|
Facter::Util::Resolution.expects(:which).with("java").at_least(1).returns(false)
|
||||||
expect(Facter.value(:java_default_home)).to be_nil
|
expect(Facter.value(:java_default_home)).to be_nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -7,13 +7,14 @@ describe Facter::Util::Fact do
|
|||||||
|
|
||||||
describe "java_version" do
|
describe "java_version" do
|
||||||
context 'returns java version when java present' do
|
context 'returns java version when java present' do
|
||||||
context 'on OpenBSD', :with_env => true do
|
context 'on OpenBSD' do
|
||||||
before do
|
before do
|
||||||
Facter.fact(:operatingsystem).stubs(:value).returns("OpenBSD")
|
Facter.fact(:operatingsystem).stubs(:value).returns("OpenBSD")
|
||||||
end
|
end
|
||||||
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
|
||||||
@@ -57,7 +61,7 @@ Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'returns nil when java not present' do
|
context 'returns nil when java not present' do
|
||||||
context 'on OpenBSD', :with_env => true do
|
context 'on OpenBSD' do
|
||||||
before do
|
before do
|
||||||
Facter.fact(:operatingsystem).stubs(:value).returns("OpenBSD")
|
Facter.fact(:operatingsystem).stubs(:value).returns("OpenBSD")
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user