Ask Your Question

Puppet 5.4.0 on ubuntu 18.04 error could not find class

asked 2018-05-08 06:05:29 -0600

vaibhav gravatar image

updated 2018-05-08 07:44:59 -0600

Mr_Sharma gravatar image

I am using puppet standalone (5.4.0) on ubuntu 18.04. While running the mainfest file i get the error :

Error: Evaluation Error: Error while evaluating a Function Call, Could not find class ::xxxxxx for hostname_vai (file: test.pp, line: 10, column: 2) on node hostname_vai

the module is located in /usr/share/puppet/modules/ and the value for various puppet variables are :

basemodulepath = /lhome/sde/.puppet/etc/code/modules:/usr/share/puppet/modules
environmentpath = /lhome/sde/.puppet/etc/code/environments
factpath = /lhome/sde/.puppet/cache/lib/facter:/lhome/sde/.puppet/cache/facts
modulepath = /usr/share/puppet/modules
edit retag flag offensive close merge delete


Did you use puppet parser validate?

Mr_Sharma gravatar imageMr_Sharma ( 2018-05-08 07:49:55 -0600 )edit

Yes, it does not shows any error. Also the same script worked fine in ubuntu 16.04 with puppet 3.8

vaibhav gravatar imagevaibhav ( 2018-05-08 11:54:07 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2018-05-08 13:49:48 -0600

binford2k gravatar image

The class and module should follow the autoloading conventions. If the manifest defining the class doesn't exist where Puppet expects it to be, then it won't be found and you'll see this error.

Basically, if your class is named foo, and your $modulepath is /usr/share/puppet/modules, then the file must be located at /usr/share/puppet/modules/foo/manifests/init.pp and must declare a class foo.

However, you should validate those assumptions. I see that you're using puppet apply. You should check those settings by running puppet apply --configprint modulepath to see where Puppet is actually looking. Use --environment $name_of_your_env if you're not running against the production environment.

edit flag offensive delete link more

answered 2018-07-05 14:56:22 -0600

Jim gravatar image

I faced the same issue with Ubuntu 18.04 in a Vagrant guest, using the Puppet 5.4.0 Ubuntu package. I was attempting to provision the guest with vagrant provision --provision-with puppet. However, all the forge modules that were included in my module were not being loaded, and I saw the same error you saw. It turned out that the vagrant provisioner command constructs a puppet apply command which looks like this:

puppet apply --modulepath '/tmp/vagrant-puppet/modules-20bb7ece7b1586037c4a2b47af5afc21:/etc/puppet/modules' ...

(if you run vagrant provision --provision-with puppet --debug you can see the puppet apply command)

The main point is that /etc/puppet/modules is in the modulepath, but that isn't where the forge module code is downloaded to anymore: it's in /etc/puppet/code/modules. Quick fix for me was to add a shell provisioner command to Vagrantfile to symlink to the correct path:

test -L /etc/puppet/modules || ln -s /etc/puppet/code/modules /etc/puppet/modules

Maybe a better fix will become available in Vagrant in the fullness of time.

I don't know whether this is the cause of your problem, but it sounds similar.

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

1 follower


Asked: 2018-05-08 06:05:29 -0600

Seen: 515 times

Last updated: Jul 05