Code Monkey home page Code Monkey logo

puppetlabs-java's Introduction

java

Table of Contents

  1. Overview
  2. Module Description - What the module does and why it is useful
  3. Setup - The basics of getting started with the java module
  4. Usage - Configuration options and additional functionality
  5. Reference - An under-the-hood peek at what the module is doing and how
  6. Limitations - OS compatibility, etc.
  7. License
  8. Development - Guide for contributing to the module

Overview

Installs the correct Java package on various platforms.

Module Description

The java module can automatically install Java jdk or jre on a wide variety of systems. Java is a base component for many software platforms, but Java system packages don't always follow packaging conventions. The java module simplifies the Java installation process.

Setup

Beginning with the java module

To install the correct Java package on your system, include the java class: include java.

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:

class { 'java':
  distribution => 'jre',
}

To install the latest patch version of Java 8 on CentOS

class { 'java' :
  package => 'java-1.8.0-openjdk-devel',
}

The defined type java::download installs one or more versions of Java SE from a remote url. java::download depends on puppet/archive.

To install Java to a non-default basedir (defaults: /usr/lib/jvm for Debian; /usr/java for RedHat):

java::download { 'jdk8' :
  ensure  => 'present',
  java_se => 'jdk',
  url     => 'http://myjava.repository/java.tgz",
  basedir => '/custom/java',
}

AdoptOpenJDK

The defined type java::adopt installs one or more versions of AdoptOpenJDK Java. java::adopt depends on puppet/archive.

java::adopt { 'jdk8' :
  ensure  => 'present',
  version => '8',
  java => 'jdk',
}

java::adopt { 'jdk11' :
  ensure  => 'present',
  version => '11',
  java => 'jdk',
}

To install a specific release of a AdoptOpenJDK Java version, e.g. 8u202-b08, provide both parameters version_major and version_minor as follows:

java::adopt { 'jdk8' :
  ensure  => 'present',
  version_major => '8u202',
  version_minor => 'b08',
  java => 'jdk',
}

To install AdoptOpenJDK Java to a non-default basedir (defaults: /usr/lib/jvm for Debian; /usr/java for RedHat):

java::adopt { 'jdk8' :
  ensure  => 'present',
  version_major => '8u202',
  version_minor => 'b08',
  java => 'jdk',
  basedir => '/custom/java',
}

To ensure that a custom basedir is a directory before AdoptOpenJDK Java is installed (note: manage separately for custom ownership or perms):

java::adopt { 'jdk8' :
  ensure  => 'present',
  version_major => '8u202',
  version_minor => 'b08',
  java => 'jdk',
  manage_basedir => true,
  basedir => '/custom/java',
}

Adoptium Temurin

Adoptium Temurin is the successor of AdoptOpenJDK and is supported using the defined type java::adoptium. It depends on puppet/archive.

The java::adoptium defined type expects a major, minor, patch and build version to download the specific release. It doesn't support jre downloads as the other distributions.

java::adoptium { 'jdk16' :
  ensure  => 'present',
  version_major => '16',
  version_minor => '0',
  version_patch => '2',
  version_build => '7',
}
java::adoptium { 'jdk17' :
  ensure  => 'present',
  version_major => '17',
  version_minor => '0',
  version_patch => '1',
  version_build => '12',
}

To install Adoptium to a non-default basedir (defaults: /usr/lib/jvm for Debian; /usr/java for RedHat):

java::adoptium { 'jdk7' :
  ensure  => 'present',
  version_major => '17',
  version_minor => '0',
  version_patch => '1',
  version_build => '12',
  basedir => '/custom/java',
}

To ensure that a custom basedir is a directory before Adoptium is installed (note: manage separately for custom ownership or perms):

java::adoptium { 'jdk8' :
  ensure  => 'present',
  version_major => '17',
  version_minor => '0',
  version_patch => '1',
  version_build => '12',
  manage_basedir => true,
  basedir => '/custom/java',
}

SAP Java (sapjvm / sapmachine)

SAP also offers JVM distributions. They are mostly required for their SAP products. In earlier versions it is called "sapjvm", in newer versions they call it "sapmachine".

The defined type java::sap installs one or more versions of sapjvm (if version 7 or 8) or sapmachine (if version > 8) Java. java::sap depends on puppet/archive. By using this defined type with versions 7 or 8 you agree with the EULA presented at https://tools.hana.ondemand.com/developer-license-3_1.txt!

java::sap { 'sapjvm8' :
  ensure  => 'present',
  version => '8',
  java => 'jdk',
}

java::sap { 'sapmachine11' :
  ensure  => 'present',
  version => '11',
  java => 'jdk',
}

To install a specific release of a SAP Java version, e.g. sapjvm 8.1.063, provide parameter version_full:

java::sap { 'jdk8' :
  ensure  => 'present',
  version_full => '8.1.063',
  java => 'jdk',
}

To install SAP Java to a non-default basedir (defaults: /usr/lib/jvm for Debian; /usr/java for RedHat):

java::adopt { 'sapjvm8' :
  ensure  => 'present',
  version_full => '8.1.063',
  java => 'jdk',
  basedir => '/custom/java',
}

To ensure that a custom basedir is a directory before SAP Java is installed (note: manage separately for custom ownership or perms):

java::adopt { 'sapjvm8' :
  ensure  => 'present',
  version_full => '8.1.063',
  java => 'jdk',
  manage_basedir => true,
  basedir => '/custom/java',
}

Reference

For information on the classes and types, see the REFERENCE.md. For information on the facts, see below.

Facts

The java module includes a few facts to describe the version of Java installed on the system:

  • java_major_version: The major version of Java.
  • java_patch_level: The patch level of Java.
  • java_version: The full Java version string.
  • java_default_home: The absolute path to the java system home directory (only available on Linux). For instance, the java executable's path would be ${::java_default_home}/jre/bin/java. This is slightly different from the "standard" JAVA_HOME environment variable.
  • java_libjvm_path: The absolute path to the directory containing the shared library libjvm.so (only available on Linux). Useful for setting LD_LIBRARY_PATH or configuring the dynamic linker.

Note: The facts return nil if Java is not installed on the system.

Limitations

For an extensive list of supported operating systems, see metadata.json

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.

Oracle Java packages are not included in Debian 7 and Ubuntu 12.04/14.04 repositories. To install Java on those systems, you'll need to package Oracle JDK/JRE, and then the module can install the package. For more information on how to package Oracle JDK/JRE, see the Debian wiki.

This module is officially supported for the following Java versions and platforms:

OpenJDK is supported on:

  • Red Hat Enterprise Linux (RHEL) 7, 8, 9
  • CentOS 7, 8
  • Oracle Linux 7
  • Debian 10, 11
  • Ubuntu 18.04, 20.04, 22.04
  • Solaris 11
  • SLES 12, 15

Oracle Java is supported on:

  • CentOS 7
  • CentOS 8
  • Red Hat Enterprise Linux (RHEL) 7

AdoptOpenJDK Java is supported on:

  • CentOS
  • Red Hat Enterprise Linux (RHEL)
  • Amazon Linux
  • Debian

Adoptium Temurin Java is supported on:

  • CentOS
  • Red Hat Enterprise Linux (RHEL)
  • Amazon Linux
  • Debian

SAP Java 7 and 8 (=sapjvm) are supported (by SAP) on:

  • SLES 12, 15
  • Oracle Linux 7, 8
  • Red Hat Enterprise Linux (RHEL) 7, 8

(however installations on other distributions mostly also work well)

For SAP Java > 8 (=sapmachine) please refer to the OpenJDK list as it is based on OpenJDK and has no special requirements.

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 packages install Java JRE/JDK in a unique directory structure, not linking the binaries to a standard directory. Because of that, the path to this location is hardcoded in the java_version fact. Whenever you upgrade Java to a newer version, you have to update the path in this fact.

License

This codebase is licensed under the Apache2.0 licensing, however due to the nature of the codebase the open source dependencies may also use a combination of AGPL, BSD-2, BSD-3, GPL2.0, LGPL, MIT and MPL Licensing.

Development

Puppet modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. To contribute to Puppet projects, see our module contribution guide.

Contributors

The list of contributors can be found at https://github.com/puppetlabs/puppetlabs-java/graphs/contributors.

puppetlabs-java's People

Contributors

adrianiurca avatar bastelfreak avatar bmjen avatar brettporter avatar chelnak avatar daianamezdrea avatar david22swan avatar davids avatar eimlav avatar eputnam avatar fraenki avatar garethr avatar glennsarti avatar gspatton avatar hunner avatar jordanbreen28 avatar kbarber avatar lionce avatar lukasaud avatar malikparvez avatar michaeltlombardi avatar pmcmaw avatar rajat-puppet avatar ramesh7 avatar sanfrancrisko avatar sheenaajay avatar shuebnersr avatar timdeluxe avatar tphoney avatar vstone avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

puppetlabs-java's Issues

Debian preseed required

To install the debian packages you need to provide a preseed responsefile to the package resource.

Add Windows Support

It would be really nice if this could support installing the JDK and JRE on Windows environments.

Add support for "install_options"

Some package providers such as apt automatically pull in recommended and/or suggested packages. This can be disabled with an option to package:

package { 'java':
   name => ...,
   ensure => present,
   install_options => ['--no-install-recommends', '--install-suggests']
}

But puppetlabs-java currently does not support the install_options flag.

Expand the README

The README is really sparse right now. Could we please expand it, to answer questions like:

  • How do we specify Java version(s) to install?
  • How do we install JDKs and/or JREs?
  • How do we install Oracle vs Open JVMs?

facter error if no java is installed

version 9.0.0 produces a facter error if the module is installed on a machine with no java installation.
This happens even if the module isnt being called since its happening at fact resolution.
The error is

Error: Facter: Error while resolving custom fact fact='java_version', resolution='': unexpected return

Support for Debian 12

Use Case

To be able to manage jdk/jre packages on debian 12 boxes

Describe the Solution You Would Like

That the module can manage jdk and/or jre packages on debian 12

Support ensured => purged and/or ensured => absent

It is not uncommon to want to REMOVE something.

Therefore, it would be helpful to support ensure => purged and/or ensure => absent.

There seems to be a bug in either Puppet 2.7 or the Oracle RPM that makes ensure => purged not work (it always says created).

A workaround is something like this for init.pp:

  validate_re($version, 'purged|present|installed|latest|^[._0-9a-zA-Z:-]+$')

  # deleted

  case $version {
    'purged': {
      exec {
        "removepackage_$use_java_package_name":
        # Do it "manually" because either Puppet RPM handling bad, or Java RPM can't handle
        command => "/usr/bin/yum -y erase $use_java_package_name",
        onlyif  => "/bin/rpm -ql $use_java_package_name";
      }    
    }
    default: {
      package { 'java':
        ensure => $version,
        name   => $use_java_package_name,
      }
    }
  }

AArch64 support

Use Case

The ARM architecture, more specifically AArch64, is getting more popular.
The current implementation only supports x86 and alike installations, but not for any other architecture.

Describe the Solution You Would Like

I would like the ability to use this module to install Java on an AArch64 machine.

Describe Alternatives You've Considered

  • Directly installing the java package with the package manager
    • This pulls operating system specific logic to the calling module.

Additional Context

I've created a branch that works for our specific use case.
But I'm not entirely sure it will handle all environments as expected.
https://github.com/0Rick0/puppetlabs-java/tree/feature/support-aarch64

It might also be useful to support other architectures like MIPS, PPC and ARMHF

Give the user an option for installing distro java

While its nice to have the 'official' oracle java package, its often less quality then what the distros ship. This is especially going to be an issue when you come to things like Java/Tomcat bundle - as the Redhat Tomcat/Java bundle is nice when managed correctly.

When users install the Java from Redhat, they get support for it from Redhat as well - Oracle's bundle is not supported so not all users would want this and we shouldn't force it onto them.

I think a generic approach is nice - so this module should support multiple potential options. Not sure if this is 1 ticket or multiple though :-).

installing oracle java

does it module actually manage to install it oracle java? I does not for me and I could not find any code that make that possible (only oracle can distribute it).

Undefined Method

Might be doing something wrong here, but in trying to apply this manifest straight out of the repo, I got:

undefined method `any?' for "^jdk$|^jre$":String at /etc/puppet/modules/java/manifests/init.pp:19 on node...

Looking at validate_re shows that it's expecting an Array, b/c of the call to .any?. I was able to fix the issue by wrapping []'s around the strings being passed into validate_re like so:

  validate_re($distribution, ['^jdk$|^jre$'])
  validate_re($version, ['installed|^[._0-9a-zA-Z:-]+$'])

Not sure if the fix should be on the validate_re side or the init.pp

Include Subversions in java::download archive paths

Use Case

When upgrading GraalVM Java Subversions over Puppet (i.e. jdk 17.0.4 -> graalvm-22.2 and jdk 17.0.5->graalvm-22.3) my current way to provision needs a workaround in order to function:

file {'/tmp/jdk-0-linux-x64.tar.gz':
    ensure => absent
  }
java::download {'GraalVM-22.3':
    ensure => 'present',
    java_se => 'jdk',
    version => '17',
    version_major => '0',
    version_minor => '5',
    package_type => 'tar.gz',
    url=> 'https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.0/graalvm-ce-java17-linux-amd64-22.3.0.tar.gz',
    basedir => '/opt/java',
  } 

This is due to the naming of the archive package in download.pp as it does not include subversions. Therefore, if still existing the old archive file will be used and the update will not be successful.

Describe the Solution You Would Like

Include the $version and $minor_release in the naming of the archive-name resulting in jdk-17-0-5-linux-x64.tar.gz

Additional Context

I have already included the changes in a fork and will do a PR if no objections are raised.

Debian preseed required

To install the debian packages you need to provide a preseed responsefile to the package resource.

Support for multiple java installs

It would be handy to allow installation of multiple java instances per machine. Obviously only one would be the default java but others could co-exist.

dummy_kermi_test

Describe the Bug

A clear and concise description of what the bug is.

Expected Behavior

A clear and concise description of what you expected to happen.

Steps to Reproduce

Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'

Environment

  • Version [e.g. 1.27.0]
  • Platform [e.g. Ubuntu 18.04]

Additional Context

Add any other context about the problem here.

OS version check prevents usage on unsupported platforms

Use Case

Sometimes it happens that stuff runs on legacy platforms for reasons. The code in
https://github.com/puppetlabs/puppetlabs-java/blob/main/manifests/init.pp#L97-L106 prevents the use of the module on unsupported platforms. This pattern is quite unique to this module. For example it prevents the use of the same module on Debian 9 (supported until v10.x.x) and Debian 12 (supported since v11.x.x)
When a new version is released user should be able to define default values in his own environment and allow the use on an unsupported platform.

Describe the Solution You Would Like

Remove the failure on unsupported platforms.

Describe Alternatives You've Considered

Having separate branches of the control repo with different module versions. I prefer a single main branch for all environments though. Multiple control-repo branches lead to merge overhead and/or rotting branches.
Different module versions in different branches can also become an issue with inconsistent types.

Additional Context

https://puppetcommunity.slack.com/archives/CFD8Z9A4T/p1713871729247549

java::adopt reinstalls every Puppet run

Describe the Bug

As per subject, java::adopt reinstalls every time the puppet agent is run.

Expected Behavior

Should only install if the package does not already exist.

Steps to Reproduce

 java::adopt { 'jre' :
   ensure  => 'present',
   version => '11',
   java    => 'jre',
 }

Environment

  • java module version: 7.3.0
  • Puppet server Version 6.18.0
  • Platform CentOS 7

Additional Context

It would not normally matter, except that every time Java is reinstalled, it replaces the cacerts database.

I am also open to workarounds if there is no fix.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.