Diagnose error with simple tutorial in "Learning Puppet 4"?

270 views
Skip to first unread message

David Karr

unread,
May 17, 2016, 3:38:36 PM5/17/16
to Puppet Users
I'm stepping through "Learning Puppet 4".  I'm on the chapter that builds a simple custom module.  I've followed the instructions as far as I can tell, but when I try to apply the module, I get the following:

[vagrant@client modules]$ puppet apply --environment test ../manifests/
Error: Evaluation Error: Error while evaluating a Method call, Could not find class ::puppet::agent for client.example.com at /etc/puppetlabs/code/environments/test/manifests/site.pp:6:43 on node client.example.com

I'm sure I've done something wrong, but I can't see it.

Here's the "site.pp" file being referenced:
notify { 'UsingTest':
    message
=> "Processing catalog from the Test environment.",
}

# lookup all classes defined in hiera and other data sources
lookup
('classes', Array[String], 'unique').include

And here's the modules "init.pp" manifest (although I get the same error when I comment out the entire body of the class definition):
class puppet {
 
# install puppet-agent
 
package { 'puppet-agent':
   
ensure => 'latest',
    notify
=> Service['puppet'],
 
}

 
# manage the puppet service
  service
{ 'puppet':
   
ensure => 'running',
    enable
=> true,
    subscribe
=> Package['puppet-agent'],
 
}
}

What else could I do to get more information?

Henrik Lindberg

unread,
May 17, 2016, 4:07:51 PM5/17/16
to puppet...@googlegroups.com
On 17/05/16 21:38, David Karr wrote:
> I'm stepping through "Learning Puppet 4". I'm on the chapter that
> builds a simple custom module. I've followed the instructions as far as
> I can tell, but when I try to apply the module, I get the following:
>
> |
> [vagrant@client modules]$ puppet apply --environment test ../manifests/
> Error:EvaluationError:Errorwhileevaluating a Methodcall,Couldnotfind
> class::puppet::agent forclient.example.com at
> /etc/puppetlabs/code/environments/test/manifests/site.pp:6:43on node
> client.example.com
> |
>
> I'm sure I've done something wrong, but I can't see it.
>
> Here's the "site.pp" file being referenced:
> |
> notify {'UsingTest':
> message =>"Processing catalog from the Test environment.",
> }
>
> # lookup all classes defined in hiera and other data sources
> lookup('classes',Array[String],'unique').include

Here you are including classes that comes from lookup (i.e. hiera, or
your data providers). One of those values are "puppet::agent".

Do you have a class called 'puppet::agent' ? Your sample has a class
named 'puppet' but no 'puppet::agent'.

- henrik

> |
>
> And here's the modules "init.pp" manifest (although I get the same error
> when I comment out the entire body of the class definition):
> |
> classpuppet {
> # install puppet-agent
> package{'puppet-agent':
> ensure=>'latest',
> notify =>Service['puppet'],
> }
>
> # manage the puppet service
> service {'puppet':
> ensure=>'running',
> enable =>true,
> subscribe =>Package['puppet-agent'],
> }
> }
> |
>
> What else could I do to get more information?
>
> --
> 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
> <mailto:puppet-users...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/3bed74c7-5ade-43a0-b19a-8fcb1b735d60%40googlegroups.com
> <https://groups.google.com/d/msgid/puppet-users/3bed74c7-5ade-43a0-b19a-8fcb1b735d60%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.


--

Visit my Blog "Puppet on the Edge"
http://puppet-on-the-edge.blogspot.se/

David Karr

unread,
May 17, 2016, 4:44:40 PM5/17/16
to Puppet Users
On Tuesday, May 17, 2016 at 1:07:51 PM UTC-7, Henrik Lindberg wrote:
On 17/05/16 21:38, David Karr wrote:
> I'm stepping through "Learning Puppet 4".  I'm on the chapter that
> builds a simple custom module.  I've followed the instructions as far as
> I can tell, but when I try to apply the module, I get the following:
>
> |
> [vagrant@client modules]$ puppet apply --environment test ../manifests/
> Error:EvaluationError:Errorwhileevaluating a Methodcall,Couldnotfind
> class::puppet::agent forclient.example.com at
> /etc/puppetlabs/code/environments/test/manifests/site.pp:6:43on node
> client.example.com
> |
>
> I'm sure I've done something wrong, but I can't see it.
>
> Here's the "site.pp" file being referenced:
> |
> notify {'UsingTest':
>     message =>"Processing catalog from the Test environment.",
> }
>
> # lookup all classes defined in hiera and other data sources
> lookup('classes',Array[String],'unique').include

Here you are including classes that comes from lookup (i.e. hiera, or
your data providers). One of those values are "puppet::agent".

Do you have a class called 'puppet::agent' ? Your sample has a class
named 'puppet' but no 'puppet::agent'.

Ok, so would the following be a simple hack that would at least get past this error?
class puppet {

 
# install puppet-agent
 
package { 'puppet-agent':

   
ensure => 'latest',

    notify
=> Service['puppet'],
 
}

 
# manage the puppet service
  service
{ 'puppet':

   
ensure => 'running',

    enable
=> true,
    subscribe
=> Package['puppet-agent'],
 
}

}

class puppet::agent {
}

 I verified this at least (although I have to run "puppet apply" as root to get past a "The yum provider can only be used as root" error).

Patrick Ryll

unread,
May 30, 2016, 11:27:23 PM5/30/16
to Puppet Users
This solution worked for me, thanks.  Is there any chance someone could put this on the Puppet 4 Errata page and/or inform Jo Rhett of this issue?  It doesn't seem to be included as of yet (May 30th, 2016) in the O'Reilly errata.  Thanks...I'll be happy to do it myself, but since I didn't really figure this out...anyway, very helpful thanks.

David M. Karr

unread,
May 31, 2016, 12:43:50 AM5/31/16
to puppet...@googlegroups.com


On 05/30/2016 07:41 PM, Patrick Ryll wrote:
This solution worked for me, thanks.  Is there any chance someone could put this on the Puppet 4 Errata page and/or inform Jo Rhett of this issue?  It doesn't seem to be included as of yet (May 30th, 2016) in the O'Reilly errata.  Thanks...I'll be happy to do it myself, but since I didn't really figure this out...anyway, very helpful thanks.

I sent it indirectly to Jo a while ago (to the O'Reilly booktech email address).  I didn't submit it directly to errata because I wasn't confident that was exactly the correct solution.  He will eventually see it.

On Tuesday, May 17, 2016 at 3:38:36 PM UTC-4, David Karr wrote:
I'm stepping through "Learning Puppet 4".  I'm on the chapter that builds a simple custom module.  I've followed the instructions as far as I can tell, but when I try to apply the module, I get the following:

[vagrant@client modules]$ puppet apply --environment test ../manifests/
Error: Evaluation Error: Error while evaluating a Method call, Could not find class ::puppet::agent for client.example.com at /etc/puppetlabs/code/environments/test/manifests/site.pp:6:43 on node client.example.com

I'm sure I've done something wrong, but I can't see it.

Here's the "site.pp" file being referenced:
notify { 'UsingTest':
    message
=> "Processing catalog from the Test environment.",
}

# lookup all classes defined in hiera and other data sources
lookup
('classes', Array[String], 'unique').include

And here's the modules "init.pp" manifest (although I get the same error when I comment out the entire body of the class definition):
class puppet {
 
# install puppet-agent
 
package { 'puppet-agent':
   
ensure => 'latest',
    notify
=> Service['puppet'],
 
}

 
# manage the puppet service
  service
{ 'puppet':
   
ensure => 'running',
    enable
=> true,
    subscribe
=> Package['puppet-agent'],
 
}
}

What else could I do to get more information?
--
You received this message because you are subscribed to a topic in the Google Groups "Puppet Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/puppet-users/NRgYyd7FV8U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/3b430fa8-5386-4999-84bd-b26a687ddea3%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages