How Do You Create a Puppet Manifest to Install Java?

Problem scenario
You have Puppet agent and Puppet Master set up and configured to work together. You are are running open source Puppet 5.x on Ubuntu servers in AWS. You want to install Java on the Puppet agent nodes. You tried to use the Java module.

On the Puppet Master server, you ran this: puppet module install puppetlabs-java --version 2.2.0

This is your site.pp file:

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

You ran this command sudo puppet apply site.pp on the Puppet master but you got this:

Error: Evaluation Error: Error while evaluating a Resource Statement, Could not find declared class puppetlabs-java at /etc/puppetlabs/code/environments/production/manifests/site.pp:11:1 on node

On the Puppet agent node you ran sudo /opt/puppetlabs/bin/puppet agent -t -d and you received this message:

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Could not find declared class java at /etc/puppetlabs/code/environments/production/manifests/site.pp:11:1 on node ip-172-31-11-23.us-east-2.compute.internal
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

How do you create a manifest to deploy Java?

Solution
Install the Puppet module with the sudo command. If you do not use sudo, it will seem to work. But the 500 error with the Puppet agent is a tell-tale sign of using the Puppet module command without sudo. The inability to find the declared class on the Puppet Master server is another example of having installed a Puppet module without using the sudo command.

Finally the manifest should be changed to this:

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

Run java -version to find that openjdk version 1.8 has been installed.

Join the Conversation

2 Comments

  1. I tried what ever is mentioned here but getting this error (pasted below) on the agent can you please help me resolve
    Error: Could not retrieve catalog from remote server: Error 500 on SERVER: rver Error: Evaluation Error: Error while evaluating a Function Call, unsuprted release bionic (file: /etc/puppet/code/environments/production/modulesava/manifests/params.pp, line: 174, column: 20) on node ip-172-31-90-24.ec2nternal

  2. I am sorry, the procedure mentioned above worked perfectly, I made a mistake somewhere while following the procedure

Leave a comment

Your email address will not be published. Required fields are marked *