Why puppet is giving errors?

Hi @juliettet @akshayyw @player001 I’ve assigned a task to setup NTP via puppet but I am facing the error below:
Error: Evaluation Error: Error while evaluating a Resource Statement, Could not find declared class ntp (file: /etc/puppetlabs/code/environments/production/manifests/news.pp, line: 1, column: 1) on node jump_host.stratos.xfusioncorp.com

My puppet file is:

class { 'ntp':
   servers => ['2.north-america.pool.ntp.org'],

class ntpconfig {
   include ntp

node 'stapp01.stratos.xfusioncorp.com','stapp02.stratos.xfusioncorp.com','stapp03.stratos.xfusioncorp.com' {
  include ntpconfig

what’s the issue?

Hi @ashu,

I see a couple of issues:

  1. Only one class needs to be created for this task:

     class ntpconfig{
  2. Then you need to install the ntp server within the ntpconfig class:

     package { 'ntp':
         ensure  => present,
  3. …+ make sure that is is present via the default NTP config file:

     # note: this block of code is also placed within the ntpconfig class
      file { '/etc/ntp.conf': 
          ensure  => present,
          content => "2.north-america.pool.ntp.org",

…then after you include ntpconfig within your server(s) (which you have already done) block add:

node default {}

…then validate you file before applying it:

puppet parser validate ecommerce.pp

Let me know if this helps!


1 Like

Greetings @juliettet
I’ve taken a reference from your solution but unfortunately the task is failed and the reason was the server name.
I think it is mandatory to write as
content => "server 2.north-america.pool.ntp.org"
rather than just
content => "2.north-america.pool.ntp.org"

due to this prefix “server” thing the task got failed :slight_smile:

But no issues, thank you so much for your help.

1 Like

@Ashu27, as per question, the content should be server 2.north-america.pool.ntp.org instead of 2.north-america.pool.ntp.org.

Please put this in reivew, you will get an another chance to attempt the task.


Hi @Ashu27,

You are correct: You do need to add server 2.north-america.pool.ntp.org . That’s what I did on my task. I just copy pasted your server IP as not to confuse you with the one that I had and forgot to prefix it with server.

If you fix that one thing, you should now be able to pass the task.

Cheers :slight_smile:

1 Like

Hi @rahul456 I’ve requested a review for this.

Hi @juliettet @rahul456 I was able to complete the task now.
Thank you so much for your support.
Cheers to you.

1 Like

Awesome! Great work @Ashu27!