1

When including a role in the site.pp file, I get the error "Could not find class roles::developmentmachine"

In my site.pp I have:

node 'laraveldev2-VirtualBox.local' {
    include roles::developmentmachine
}

In my modules folder (/etc/puppetlabs/code/environments/production/modules) I have a roles folder.

Partial tree for modules folder:

 └── roles
     ├── developmentmachine
     │   └── init.pp
     └── init.pp

The developmentmachine/init.pp has:

class roles::developmentmachine {
    # Code here
}

I have checked the module path and it is correct (as given above).

To my knowledge, writing include roles::developmentmachine says "include a class in the roles folder, inside the modules folder, called developmentmachine" so this should be fine.

If anyone sees a problem with this or has a suggestion, please let me know.

Many thanks

1 Answers1

1

The top-level init.pp file is only for classes having their module name as their fully-qualified name. In your "roles" module, that would be a class named "roles" (absolute: ::roles).

Other class definitions should go in manifest files named after the class. For example, the definition for a class named roles::developmentmachine should appear in file modules/roles/manifests/developmentmachine.pp. Puppet does not find your class because you have put it elsewhere.

If you have more than two segments in a fully-qualified class or defined-type name, then that corresponds to substructure of the corresponding manifest directory. It does not, however, alter any of the proceeding, and in no event does the special significance of the init.pp file apply in subdirectories of a module's manifest directory. Thus, a file modules/roles/manifests/developmentmachine/init.pp is where Puppet would look for the definition of a class named roles::developmentmachine::init.

John Bollinger
  • 160,171
  • 8
  • 81
  • 157