Hi I'm new to puppet and I'm trying to make a test class, but when I run puppet apply-t
I get error Error: Evaluation Error: Error while evaluating a Function Call, Could not find class ::heroes
for
under my test directory I have
.
├── examples
│ ├── init.pp
│ └── superhero.pp
└── manifests
├── init.pp
└── superhero.pp
2 directories, 4 files
in my superhero.pp
under manifest the code reads
class heroes {
user { 'thor':
ensure => present,
}
}
in my superhero.pp
under example the code reads
include heroes
Not sure why when I run puppet apply --noop superheroes.pp
under examples that error shows up?
Here is my complete tree under modules
├── hosts
│ ├── examples
│ │ └── init.pp
│ └── manifests
│ └── init.pp
├── nginx
│ ├── examples
│ │ └── init.pp
│ ├── files
│ │ ├── default.conf
│ │ ├── index.html
│ │ └── nginx.conf
│ ├── index.html
│ └── manifests
│ ├── index.html
│ └── init.pp
├── test
│ ├── examples
│ │ ├── admins.pp
│ │ ├── init.pp
│ │ └── superhero.pp
│ └── manifests
│ ├── admins.pp
│ ├── init.pp
│ └── superhero.pp
└── users
├── examples
│ ├── admins.pp
│ └── init.pp
└── manifests
├── admins.pp
└── init.pp
I think there may be two problems
First is that when running puppet apply superheroes.pp
in the examples
directory, it doesn't know where to look for other modules (like heroes
you include
). To know where to look for modules, you need to give it a modulepath:
puppet apply --modulepath=/path/to/modules --noop superhero.pp
The other problem is the location of heroes
class that you state is located in test/manifests/superhero.pp
. The rules for where Puppet is trying to find classes are described here and here. Unless you're doing something less usual such as defining a class inside another class, puppet will use the following rules to locate the class:
::
) identifies module.init.pp
, otherwise file name is the last segment with .pp
extensionmanifests
directory.The path where puppet will look is
<modulepath>/<module name>/manifests/<subdirectories>.../<file name>.pp
Here is an example from the documentation:
== class name == == path ==
apache <module path>/apache/manifests/init.pp
apache::mod <module path>/apache/manifests/mod.pp
apache::mod::passenger <module path>/apache/manifests/mod/passenger.pp
Returning back to your question: Upon include heroes
, puppet will look in <modulepath>/heroes/manifests/init.pp
. Conversely, to make puppet look in test/manifests/superhero.pp
, you would need to include class test::superhero
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With