I am doing "sudo puppet agent --test" in puppet slave, I am getting below error.
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: A substring operation does not accept a String as a character index. Expected an Integer (file: /etc/puppet/code/environments/production/modules/java/manifests/init.pp, line: 60, column: 20) on node puppet-slave1.us-central1-a.c.vernal-sunspot-255718.internal
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
Also, you can refer to the below code:
# Class: java
# ===========================
#
# Full description of class java here.
#
# Parameters
# ----------
#
# Document parameters here.
#
# * `sample parameter`
# Explanation of what this parameter affects and what it defaults to.
# e.g. "Specify one or more upstream ntp servers as an array."
#
# Variables
# ----------
#
# Here you should define a list of variables that this module would require.
#
# * `sample variable`
# Explanation of how this variable affects the function of this class and if
# it has a default. e.g. "The parameter enc_ntp_servers must be set by the
# External Node Classifier as a comma separated list of hostnames." (Note,
# global variables should be avoided in favor of class parameters as
# of Puppet 2.6.)
#
# Examples
# --------
#
# @example
# class { 'java':
# servers => [ 'pool.ntp.org', 'ntp.local.company.com' ],
# }
#
# Authors
# -------
#
# Author Name <[email protected]>
#
# Copyright
# ---------
#
# Copyright 2020 Your name here, unless otherwise noted.
#
class java {
exec { "Test for Java":
command => '/bin/echo java is not installed > /tmp/java_notinstall.txt',
unless => '/bin/which java',
}
package { 'openjdk-8-jre-headless':
ensure => installed,
require => exec['Test for Java'],
}
}
Please help me to solve this issue.