Skip to content

Commit

Permalink
Update module to add the a custom URL Feature.
Browse files Browse the repository at this point in the history
```puppet
class { 'jdk_oracle':
  jce                              => true,
  default                    => true,
  download_url     => 'https://nexus.corp/java',
  proxy_host           => 'http://proxyhost:3128',
  version_update => '102',
  version_build      => '14',
}
```

Refactored the whole module to use
* puppet-archive to simplify archive download and extraction
* puppet-alternatives to simplify alternatives setup

Refactored spec tests
Added Acceptance tests with beaker

Working under debian 8 and centos 6.7 for jdk8/jdk7/jre8 with/without JCE

Should work on major RedHat based release as well as Debian.

** not tested with suse **
  • Loading branch information
vfoucault committed Oct 18, 2016
1 parent d8e4a99 commit 8d1cfae
Show file tree
Hide file tree
Showing 15 changed files with 774 additions and 328 deletions.
85 changes: 82 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,83 @@
spec/fixtures
pkg/
# Default .gitignore for Ruby
*.gem
*.rbc
.bundle
.vendor
.config
coverage
InstalledFiles
lib/bundler/man
pkg
rdoc
spec/reports
test/tmp
test/version_tmp
tmp

# YARD artifacts
.yardoc
_yardoc
doc/

# Vim
*.swp

# OS X
.DS_Store

# Puppet
coverage/
spec/fixtures/modules/*
spec/fixtures/manifests/*
Gemfile.lock

# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff:
.idea/workspace.xml
.idea/tasks.xml
.idea/dictionaries
.idea/vcs.xml
.idea/jsLibraryMappings.xml

# Sensitive or high-churn files:
.idea/dataSources.ids
.idea/dataSources.xml
.idea/dataSources.local.xml
.idea/sqlDataSources.xml
.idea/dynamic.xml
.idea/uiDesigner.xml

# Gradle:
.idea/gradle.xml
.idea/libraries

# Mongo Explorer plugin:
.idea/mongoSettings.xml

## File-based project format:
*.iws

## Plugin-specific files:

# IntelliJ
/out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

.idea/
*.iml

log/*

junit/*
19 changes: 4 additions & 15 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,9 @@ rvm:
script:
- "bundle exec rake lint"
- "bundle exec rake spec SPEC_OPTS='--format documentation'"
env:
- PUPPET_VERSION="~> 3.0.0"
- PUPPET_VERSION="~> 3.1.0"
- PUPPET_VERSION="~> 3.2.0"
- PUPPET_VERSION="~> 3.3.0"
- "bundle exec rspec/acceptance"
matrix:
allow_failures:
- rvm: ruby-head
exclude:
- rvm: 1.9.3
env: PUPPET_GEM_VERSION="~> 2.7.0"
- rvm: ruby-head
env: PUPPET_GEM_VERSION="~> 2.7.0"
include:
- rvm 1.9.3
- PUPPET_GEM_VERSION="~> 3.0" BEAKER_set="default"
gemfile: .gemfile
notifications:
email:
- travisci@tylerwalts.com
23 changes: 23 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
source ENV['GEM_SOURCE'] || 'https://rubygems.org'

puppetversion = ENV.key?('PUPPET_VERSION') ? ENV['PUPPET_VERSION'] : ['>= 3.3']
gem 'metadata-json-lint'
gem 'puppet', puppetversion
gem 'puppetlabs_spec_helper', '>= 1.0.0'
gem 'puppet-lint', '>= 1.0.0'
gem 'facter', '>= 1.7.0'
gem 'rspec'
gem 'rspec-puppet'
gem 'beaker', '=2.51.0'
gem 'beaker-rspec'
gem 'serverspec'
gem 'pry'

# rspec must be v2 for ruby 1.8.7
if RUBY_VERSION >= '1.8.7' && RUBY_VERSION < '1.9'
gem 'rspec', '~> 2.0'
gem 'rake', '~> 10.0'
else
# rubocop requires ruby >= 1.9
gem 'rubocop'
end
66 changes: 64 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ site.pp:


## Parameters:

### Class jdk_oracle
* version
* Java Version to install
* version_update
Expand All @@ -110,6 +110,68 @@ site.pp:
* jce
* Boolean to optionally install Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files (Java 8 only)
* default_java
* Boolean to indicate if the installed java version is linked as the default java, javac etc...
* Default to false. Boolean to indicate if the installed java version is linked as the default java, javac etc...
* ensure
* Boolean to disable anything from happening (absent/removal not supported yet)
* download_url
* string: the download base url to use. default to oracle cdn. should contain the jdk directory. eg : https://custom_host -> https://custom_host/jdk/8u11-b12/jdk-8u11-linux-x64.tar.gz
* proxy_host
* a proxy host use. Default to undef.

### jdk_oracle::install
Basicaly the same option as class jdk_oracle.
* version
* Java Version to install
* version_update
* Java Version update to install
* version_build
* Java Version build to install
* install_dir
* Java Installation Directory
* use_cache
* Optionally host the installer file locally instead of fetching it each time, for faster dev & test
* platform
* The platform to use
* package
* The package to install. Can be one of the following: jdk, jre, server-jre
* jce
* Boolean to optionally install Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files (Java 8 only)
* default_java
* Default to false. Boolean to indicate if the installed java version is linked as the default java, javac etc...
* create_symlink:
* default to false. Do we have to create a symlink of java_home to the default java_home
* proxy

## Example Usage.

to install the default jdk8u11 plus jdk8u102 as default with JCE with default parameters :

```puppet
class { 'jdk_oracle':
jce => true
}
jdk_oracle::install { 'jdk_11u102':
version_update => '102',
version_build => '14',
default_java => true,
jce => true,
install_dir => '/usr/java'
}
```

to install only jdk8u102 as default with jce, with custom repository and proxy
```puppet
class { 'jdk_oracle':
jce => true,
default => true,
download_url => 'https://nexus.corp/java',
proxy_host => 'http://proxyhost:3128',
version_update => '102',
version_build => '14',
}
```




36 changes: 33 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,34 @@
require 'rubygems'
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-lint'
PuppetLint.configuration.send("disable_80chars")
require 'puppet-lint/tasks/puppet-lint'
require 'metadata-json-lint/rake_task'

if RUBY_VERSION >= '1.9'
require 'rubocop/rake_task'
RuboCop::RakeTask.new
end

PuppetLint.configuration.send('disable_80chars')
PuppetLint.configuration.relative = true
PuppetLint.configuration.ignore_paths = ['spec/**/*.pp', 'pkg/**/*.pp']

desc 'Validate manifests, templates, and ruby files'

task :validate do
Dir['manifests/**/*.pp'].each do |manifest|
sh "puppet parser validate --noop #{manifest}"
end

Dir['spec/**/*.rb', 'lib/**/*.rb'].each do |ruby_file|
sh "ruby -c #{ruby_file}" unless ruby_file =~ %r{spec/fixtures}
end
Dir['templates/**/*.erb'].each do |template|
sh "erb -P -x -T '-' #{template} | ruby -c"
end
end

desc 'Run metadata_lint, lint, validate, and spec tests.'
task :test do
[:metadata_lint, :lint, :validate, :spec, :beaker].each do |test|
Rake::Task[test].invoke
end
end
8 changes: 5 additions & 3 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@
$platform = hiera('jdk_oracle::platform', 'x64' ),
$package = hiera('jdk_oracle::package', 'jdk' ),
$jce = hiera('jdk_oracle::jce', false ),
$default_java = hiera('jdk_oracle::default_java', true ),
$default_java = hiera('jdk_oracle::default_java', false ),
$download_url = hiera('jdk_oracle::download_url', 'http://download.oracle.com/otn-pub/java'),
$proxy_host = hiera('jdk_oracle::proxy_host', undef ),
$ensure = 'installed'
) {

Expand All @@ -74,8 +76,8 @@
default_java => $default_java,
}

if ! defined(Package['wget']) {
package { 'wget':
if ! defined(Package['curl']) {
package { 'curl':
ensure => present,
}
}
Expand Down
Loading

0 comments on commit 8d1cfae

Please sign in to comment.