Could not find class, and yet it is there
So... this is a bit embarrassing, but...
Right there in my
/etc/puppet.conf file is this:
[master] manifest=$confdir/manifests/site.pp modulepath=$confdir/environments/$environment/modules:$confdir/modules
strace at it to figure out where it was hunting for files, I noticed something. It was looking for custommod under
/etc/puppet/environments/production/modules, and since there was a directory there (empty), it did not then go check
/etc/puppet/modules. Apparently when importing a module it checks for directory-presence, rather than file-presence (init.pp).
Remove that empty directory, things start working.
Run the puppet agent using a different environment, things start working.
Moral of the story:
Puppet Environment paths do not act like bash $PATH.
I ran into this same problem, but had a different fix
If you generate a puppet module like so:
puppet module generate foo-example_module
It will create a module named
example_module with the
foo name space. All the manifests will be inside a directory called
The name of the class defined in the init.pp needs to be the same as the folder name.
mv foo-example_module example_module
If you run puppet-lint, it will warn with the following message:
ERROR: example_module not in autoload module layout on line 42
If using a Puppetfile with r10k or librarian-puppet, you also may need to remove the name space so that the files are placed without the 'foo' prefix in your modules directory.
mod 'foo-example_module', :git => [email protected]:foo/example_module'
mod 'example_module', :git => [email protected]:foo/example_module'
Another problem that might happen is when your module have an invalid
Make sure the
metadata.json file have all the required fields (see https://docs.puppet.com/puppet/latest/reference/modules_metadata.html#allowed-keys-in-metadatajson )