Puppet enterprise error while running "puppet agent -t" commnad, unable to get User/Group data from hieara

666 views Asked by At

I have Puppet enterprise installed on my VM, running in Virtualbox.

The installation went fine, but when I try to run the command puppet agent -t I get the following error:

[root@puppetmaster ~]# puppet agent -t
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Function Call, Could not find data item role in any Hiera data file and no default supplied at /etc/puppetlabs/code/environments/production/manifests/site.pp:32:10 on node puppetmaster.localdomain
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

Here is my site.pp file line where the error is coming from;

## site.pp ##

# This file (/etc/puppetlabs/puppet/manifests/site.pp) is the main entry point
# used when an agent connects to a master and asks for an updated configuration.
#
# Global objects like filebuckets and resource defaults should go in this file,
# as should the default node definition. (The default node can be omitted
# if you use the console and don't define any other nodes in site.pp. See
# http://docs.puppetlabs.com/guides/language_guide.html#nodes for more on
# node definitions.)

## Active Configurations ##

# Disable filebucket by default for all File resources:
#http://docs.puppetlabs.com/pe/latest/release_notes.html#filebucket-resource-no-longer-created-by-default
File { backup => false }

# DEFAULT NODE
# Node definitions in this file are merged with node data from the console. See
# http://docs.puppetlabs.com/guides/language_guide.html#nodes for more on
# node definitions.

# The default node definition matches any node lacking a more specific node
# definition. If there are no other nodes in this file, classes declared here
# will be included in every node's catalog, *in addition* to any classes
# specified in the console for that node.

node default {
 # This is where you can declare classes for all nodes.
 # Example:
 #   class { 'my_class': }
 $role = hiera('role')
 $location = hiera('location')
 notify{"in the top level site.pp : role is '${role}', location is '${location}'": }
 include "::roles::${role}"
}
1

There are 1 answers

0
Peter Souter On

If you look at the error, it can't find the hiera key that you've asked for in your site.pp:

Could not find data item role in any Hiera data file and no default supplied at /etc/puppetlabs/code/environments/production/manifests/site.pp:32:10 on node puppetmaster.localdomain

In your code, you have the following:

$role = hiera('role')
$location = hiera('location')

Both of these are hiera calls, that require that hiera is setup and that the relevant key is in a hieradata folder.

A useful tool to help you diagnose hiera issues is hiera_explain, which shows you how your hiera hierarchy is setup and configured, and might help explain what the issue is with your code.