Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (29.3k points)

 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.

1 Answer

0 votes
by (50.2k points)
edited by

The error had happened as you've specified the exec in lowercase in Line 60 and column 20. Change the exec from lower case to upper case.

So, basically your line 60 should be like:

   require => Exec['Test for Java'], 

Refer to the screenshot attached.

For more information, check out this puppet tutorial

Related questions

+1 vote
1 answer
asked Mar 7, 2020 in DevOps and Agile by chandra (29.3k points)
0 votes
1 answer
+1 vote
1 answer
asked Aug 17, 2019 in DevOps and Agile by chandra (29.3k points)

Browse Categories

...