puppet cannot find class.

722 views
Skip to first unread message

dE

unread,
Mar 5, 2016, 5:18:22 AM3/5/16
to Puppet Users
Hi.

I've made a class in the $basemodulepath location --

puppet config print  | grep basemodulepath
basemodulepath
= /etc/puppetlabs/code/modules:/opt/puppetlabs/puppet/modules

ls
-R /etc/puppetlabs/code/modules/all_class/
/
etc/puppetlabs/code/modules/all_class/:
manifests

/etc/puppetlabs/code/modules/all_class/manifests:
dep
.pp  first_class.pp

Contents of first_class.pp --
class first_class {
        file
{ '/tmp/fclass.txt':
               
ensure => present,
                owner
=> de,
               
group => de,
       
}
        file
{ '/tmp/procs':
               
ensure => directory,
                source
=> ['puppet:///modules/filesmmodule/proc_files/'],
                owner
=> de,
               
group => root,
                mode
=> '700',
                recurse
=> true
       
}
        file
{'/tmp/procs/cpuinfo':
               
ensure => present,
                owner
=> de,
               
group => de,
       
}
       
require Class["dep"]
}

Contents of dep.pp ---
class dep {
        file
{ '/tmp/dep_file':  
               
ensure => present,
                owner
=> de
       
}
}

When I call the class from the main manifest --

Error: Evaluation Error: Error while evaluating a Resource Statement, Could not find declared class first_class at /etc/puppetlabs/code/environments/production/manifests/default.pp:1:1 on node desktopminer

It does not help if I define the class in $modulepath

Thanks for any help.

Martin Alfke

unread,
Mar 5, 2016, 6:30:17 AM3/5/16
to puppet...@googlegroups.com
Hi
On 05 Mar 2016, at 11:18, dE <de.t...@gmail.com> wrote:

> Hi.
>
> I've made a class in the $basemodulepath location --
>
> puppet config print | grep basemodulepath
> basemodulepath = /etc/puppetlabs/code/modules:/opt/puppetlabs/puppet/modules
>
> ls -R /etc/puppetlabs/code/modules/all_class/
> /etc/puppetlabs/code/modules/all_class/:
> manifests

This means you have a module with name all_class.
>
> /etc/puppetlabs/code/modules/all_class/manifests:
> dep.pp first_class.pp

And there are two classes inside the module.
>
> Contents of first_class.pp --
> class first_class {

The class is within the module namespace.
rename it to
class all_class::first_class {

> file { '/tmp/fclass.txt':
> ensure => present,
> owner => de,
> group => de,
> }
> file { '/tmp/procs':
> ensure => directory,
> source => ['puppet:///modules/filesmmodule/proc_files/'],
> owner => de,
> group => root,
> mode => '700',
> recurse => true
> }
> file {'/tmp/procs/cpuinfo':
> ensure => present,
> owner => de,
> group => de,
> }
> require Class["dep"]
> }
>
> Contents of dep.pp —

Same here:
rename to
class all_class::dep {

> class dep {
> file { '/tmp/dep_file':
> ensure => present,
> owner => de
> }
> }
>
> When I call the class from the main manifest --
>
> Error: Evaluation Error: Error while evaluating a Resource Statement, Could not find declared class first_class at /etc/puppetlabs/code/environments/production/manifests/default.pp:1:1 on node desktop miner

I suppose you have something like include first_class in your manifest.
Puppet searches for
$basemodulepath/first_class/manifests/init.pp

>
> It does not help if I define the class in $modulepath
>
> Thanks for any help.
>
> --
> You received this message because you are subscribed to the Google Groups "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/b0c4b1d7-7972-4a8e-aa71-ac2930a29513%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Sans

unread,
Mar 5, 2016, 6:36:02 AM3/5/16
to Puppet Users
I've never used a module with out a init.pp, so cannot tell you if that's the issue, I think it's not.
But normally this what I would do:


class all_class::first_class { .... } and  class all_class::dep { .... }

Probably worth giving a try.
On a general note, you should have all the
owner, group values within the single-quote. But that's not to actual issue though.

-S

dE

unread,
Mar 5, 2016, 6:51:10 AM3/5/16
to Puppet Users
Now I see the bigger picture. Looks like this documentation is wrong.

Thanks for the help everyone!
Reply all
Reply to author
Forward
0 new messages