Ask Your Question

I am learning puppet. when I create a manifest without class, it runs perfectly. but when I create a class to wrap it, the puppet runs without error, but has no change.

asked 2016-06-02 16:11:05 -0500

puppetamateur gravatar image

I am new to puppet. still learning. I want to know where does the site.pp read its classes from. I tried placing it outside modules inside puppet. but it doesn't work. I have the class defined in the init.pp file for notepadplusplus. but when I run site.pp, it cannot find the class.

  • puppet
    • site.pp
    • modules
      - notepadplusplus
             - manifests
edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted

answered 2016-06-03 14:47:02 -0500

puppetamateur gravatar image

So, I was able to solve this problem. Basically, we need to declare the class using class{ '<classname>' :}

edit flag offensive delete link more

answered 2016-06-03 20:02:01 -0500

DarylW gravatar image

Hi there! You should read through the Beginner's Guide to Modules and the Module Fundamentals guides.

There are a lot of 'convention' driven rules about how to place/name your classes so the autoloader will find them.

If you place resources in a whatever.pp file and do puppet apply whatever.pp, it will load any resources it finds. If you want something to load as a module, you need to follow a few rules.

Here is an excerpt from the Module Layout section...

This example module, my_module, shows the standard module layout in more detail:

my_module — This outermost directory’s name matches the name of the module.
manifests/ — Contains all of the manifests in the module.
init.pp — Contains a class definition. This class’s name must match the module’s name.
other_class.pp — Contains a class named my_module::other_class.
my_defined_type.pp — Contains a defined type named my_module::my_defined_type.
implementation/ — This directory’s name affects the class names beneath it.
foo.pp — Contains a class named my_module::implementation::foo.
bar.pp — Contains a class named my_module::implementation::bar.
files/ — Contains static files, which managed nodes can download.
service.conf — This file’s source => URL would be puppet:///modules/my_module/service.conf. Its contents can also be accessed with the file function, like content => file('my_module/service.conf').
lib/ — Contains plugins, like custom facts and custom resource types. These will be used by both the Puppet master server and the Puppet agent service, and they’ll be synced to all agent nodes whenever they request their configurations. See “Using Plugins” for more details.
facts.d/ — Contains external facts, which are an alternative to Ruby-based custom facts. These will be synced to all agent nodes, so they can submit values for those facts to the Puppet master. (Requires Facter 2.0.1 or later.)
templates/ — Contains templates, which the module’s manifests can use. See “Templates” for more details.
component.erb — A manifest can render this template with template('my_module/component.erb').
component.epp — A manifest can render this template with epp('my_module/component.epp').
examples/ — Contains examples showing how to declare the module’s classes and defined types.
other_example.pp — Major use cases should have an example.
spec/ — Contains spec tests for any plugins in the lib directory.

Let us know if you have any additional questions!

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2016-06-02 12:15:50 -0500

Seen: 71 times

Last updated: Jun 03 '16