Install Oracle JDK with Puppet

Problem

You would like to install Oracle JDK using Puppet.

Using the puppetlabs/java module, you might get an error message such as:

Error: Java distribution oracle-jdk is not supported. at […]/init.pp:57 on node […]

Solution

Use the module puppet-jdk-oracle.

Just follow the installation instruction from the GitHub page.

Note that you might want to set the java version used to the latest available. You can find the latest version and build number from the Oracle JDK downloads page.

To get the build number, you first need to accept the terms and conditions and then check the URL of the link to download the version of the JDK you are interested in:

Also, make sure to configure the right platform: ‘x64’ for 64 bit systems and ‘i586’ for 32 bit systems.

UPDATE: Note that newer versions of Java 8 also require the inclusion of a hash. So the download link from Oracle will look as follows:

http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz

The part in bold is the hash.

As of 26th of Mai 2017, the configuration needs to be adjusted as follows (Thanks @Vulco, see in comments below):

Within ~/manifests/install.pp adjust the following variables:

$default_8_update = ‘131’
$default_8_build = ’11’
$default_8_hash = ‘d54c1d3a095b4ff2b6607d096fa80163’

As of 30th of April 2015, this would be the configuration for the latest JDK version on 64 bit Linux:

class { ‘jdk_oracle’:

    version => ‘8’,

    version_update => ’45’,

    version_build => ’14’,

    platform => ‘x64’,

    ensure => ‘installed’,

}

7 thoughts on “Install Oracle JDK with Puppet

  1. waste of time , am getting following error

    Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not parse for environment production: Could not match ‘jdk_oracle’: at /etc/puppet/manifests/site.pp:1 on node puppet-agent.c.dynamicmenu.internal
    Warning: Not using cache on failed catalog
    Error: Could not retrieve catalog; skipping run

      1. Getting “The requested URL returned error: 404 Not Found”. The hard coded url for the actual jdk-8u121-linux-x64.tar.gz is dead.

        Which means that every time there is an update from Oracle on Java, the link will need to be updated.

  2. Apologies.

    By editing jdk_oracle/manifests/install.pp and setting the values to the current version, build and hash. It works!

    Thanks 🙂

    1. Thank you for the update!

      What did you do exactly to get it working. I tried this the other day and it looked like Oracle have added another component to the URL?

  3. Within ~/manifests/install.pp

    The following variables need to be adjusted.

    $default_8_update = ‘131’
    $default_8_build = ’11’
    $default_8_hash = ‘d54c1d3a095b4ff2b6607d096fa80163’

    Thie info can be seen from the link used on the Oracle Java Downloads page. http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

    Note the following
    http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz

    This link tells us that its Version 8, update=u131 and build=b11
    The hash is the next section of the link.

    Perhaps with some clever scripting, one can extract that info. For now, this will have to do…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s