Ask Your Question
0

Puppet First install - Could not find class ::ntp

asked 2017-11-28 11:44:19 -0600

combobox gravatar image

updated 2017-11-30 05:23:49 -0600

Hello, team!

I'm very new on this puppet universe and i'm trying to get together a small PoC so see if puppet would be able to manage my infrastructure.

I followed a couple of receipes, installing a puppet master server and a puppet node, and right now i'm not able apply a new module on the node. The error that i get is:

# puppet agent -t
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Function Call, Could not find class ::ntp for cn23.mycorporatedomain.com at /etc/puppetlabs/code/environments/production/manifests/site.pp:2:4 on node cn23.mycorporatedomain.com
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

Even with the debug option on the error itself is not clear. I've attached the following files for help:

puppetAgent.conf

[main]
certname = cn23.mycorporatedomain.com
server = sp218.mycorporatedomain.com
environment = production
[agent]
report = true
[master]
always_cache_features = true

Puppet master tree organization

/etc/puppetlabs/
├── code/
│   ├── environments/
│   │   └── production/
│   │       ├── data/
│   │       ├── manifests/
│   │       │   └── site.pp*
│   │       ├── modules/
│   │       │   ├── ntp/
│   │       │   │   └── manifests/
│   │       │   │       └── init.pp*
│   └── modules/
├── mcollective/
│   ├── client.cfg
│   ├── data-help.erb
│   ├── discovery-help.erb
│   ├── facts.yaml
│   ├── metadata-help.erb
│   ├── rpc-help.erb
│   └── server.cfg
├── puppet/
│   ├── ssl/
│   │   ├── ca/
│   │   │   ├── private/
│   │   │   ├── requests/
│   │   │   ├── signed/
│   │   │   │   ├── cn23.mycorporatedomain.com.pem*
│   │   │   │   ├── sp218.mycorporatedomain.com.pem
│   │   │   │   └── sp227.mycorporatedomain.com.pem*
│   │   │   ├── ca_crl.pem
│   │   │   ├── ca_crt.pem
│   │   │   ├── ca_key.pem
│   │   │   ├── ca_pub.pem
│   │   │   ├── inventory.txt
│   │   │   └── serial
│   │   ├── certificate_requests/
│   │   ├── certs/
│   │   │   ├── ca.pem
│   │   │   └── sp218.mycorporatedomain.com.pem
│   │   ├── private/
│   │   ├── private_keys/
│   │   │   └── sp218.mycorporatedomain.com.pem
│   │   ├── public_keys/
│   │   │   └── sp218.mycorporatedomain.com.pem
│   │   └── crl.pem
├── puppetserver/
│   ├── conf.d/
│   │   ├── auth.conf
│   │   ├── global.conf
│   │   ├── metrics.conf
│   │   ├── puppetserver.conf
│   │   ├── web-routes.conf
│   │   └── webserver.conf
│   ├── services.d/
│   │   └── ca.cfg
│   ├── logback.xml
│   └── request-logging.xml
└── pxp-agent/
    └── modules/

Puppet node tree organization

/etc/puppetlabs/
├── code/
│   ├── environments/
│   │   └── production/
│   │       ├── data/
│   │       ├── manifests/
│   │       ├── modules/
│   │       ├── environment.conf
│   │       └── hiera.yaml
│   └── modules/
├── mcollective/
│   ├── client.cfg
│   ├── data-help.erb
│   ├── discovery-help.erb
│   ├── facts.yaml
│   ├── metadata-help.erb
│   ├── rpc-help.erb
│   └── server.cfg
├── puppet/
│   ├── ssl/
│   │   ├── ca/
│   │   │   ├── private/
│   │   │   ├── requests/
│   │   │   ├── signed/
│   │   │   ├── ca_key.pem
│   │   │   └── ca_pub.pem
│   │   ├── certificate_requests/
│   │   │   └── cn23.mycorporatedomain.com.pem
│   │   ├── certs/
│   │   │   ├── ca.pem
│   │   │   └── cn23.mycorporatedomain.com.pem
│   │   ├── private/
│   │   ├── private_keys/
│   │   │   └── cn23.mycorporatedomain.com.pem
│   │   ├── public_keys/
│   │   │   └── cn23.mycorporatedomain.com.pem
│   │   └── crl.pem
│   ├── auth.conf
│   ├── hiera.yaml
│   └── puppet.conf
└── pxp-agent/
    └── modules/

ini.pp

class ntp {

  package{'ntp':
      ensure => installed,
   }

   service{'ntpd':
      ensure => running,
      enable => true,
      require => Package['ntp'],
   }

}

site.pp

node 'cn23.mycorporatedomain.com'{
   include ntp
}

Master modules installed

puppet module list
/etc/puppetlabs/code/environments/production/modules
├── ntp (???)
├── puppetlabs-stdlib (v4.23.0)
└── corporate-spacewalk (v0.1.0)
/etc/puppetlabs/code/modules (no modules installed)
/opt/puppetlabs/puppet/modules (no modules installed)

SELinux Conf

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

Puppet Master ... (more)

edit retag flag offensive close merge delete

Comments

Hi Combobox, Can you also add the output of (from the master): puppet module list And I am not sure whether it is a mistake or not, but the tree output on your modules folder seems to highlight two manifests folders under the ntp modules (one with an executable init.pp and the other with stage/init

stivesso gravatar imagestivesso ( 2017-11-28 15:44:32 -0600 )edit

Hello, stivesso! Yeah, that was a typo. My inttention was to post only the npt tree structure. There are other 2 modules on this server that are not working as well, so i'm focusing on understanding a simple cenario with the npt module to go for a real use case implementation.

combobox gravatar imagecombobox ( 2017-11-29 05:44:37 -0600 )edit

Hi Combobox, Quite difficult to spot the cause of that Issue, do you have selinux running? Can you also check that the main Puppet Server User is able to get in modules/ntp/manifests? Just trying to see if that might be due to some missing permissions (Check also the puppetserver log output...)

stivesso gravatar imagestivesso ( 2017-11-29 13:06:17 -0600 )edit

This where things get complicated. Puppet master logs shows only the 'cannot find class' message. Probably this is why im having so much trouble finding the real issue. I added the master logs and seliunux current conf. To avoid permission issues, manifests and the init file are 777 for testing.

combobox gravatar imagecombobox ( 2017-11-29 14:10:48 -0600 )edit

Just for testing purpose, try to disable selinux (setenforce 0) and check the output...

stivesso gravatar imagestivesso ( 2017-11-30 02:55:10 -0600 )edit

2 Answers

Sort by » oldest newest most voted
0

answered 2017-12-08 10:31:40 -0600

combobox gravatar image

Hello, people!

First off all, tks for all the efforts on helping me out. It was a rich experience on my troublesome start with Puppet.

Turns out that my issue was related with folder secutity settings. Puppet master and agets were configured with root user, but the agent was using the puppet user. Using the same artifacts, but now running de generate script (puppet module generate mycorporatedomain-ntp) with the correct puppet user i was able to apply my sample ntp playblook.

We were able to check the real issue running The WEBrick Puppet master depracated version. Using this the access denied message was correctly shown.

But i'll also get a nice puppet book to properly write new custom modules and classes.

Tks!

edit flag offensive delete link more

Comments

Hello Combobox, Great to hear that you were able to find the Issue, I suspected the same (That's why I asked to check that the main Puppet Server User was able to get in modules/ntp/manifests?), but I wrongly assumed that you knew the Puppet Server User. Related to the learning,

stivesso gravatar imagestivesso ( 2017-12-09 00:25:31 -0600 )edit

besides books, there are also many great resource online.

stivesso gravatar imagestivesso ( 2017-12-09 00:26:30 -0600 )edit
0

answered 2017-12-03 12:14:03 -0600

jorhett gravatar image

updated 2017-12-03 12:15:05 -0600

So you have an NTP module within a file named ini.pp? Puppet won't find that.

And frankly, if you are trying to learn what Puppet can do for you, reinventing the wheel isn't a good way to move forward. You should start here: https://forge.puppet.com/modules?utf-...

Find one that meets your needs and then install it: $ sudo puppet module install puppetlabs/ntp

If you really want to build your own module, do this first and then compare your module against theirs to figure out what's missing. Or better yet get a good book to walks you through the module design process step by step. Obviously I have a bias when I suggest this book, but honestly it has the longest walkthrough of module development: http://shop.oreilly.com/product/06369... or https://www.safaribooksonline.com/lib...

The language didn't change so every word applies to Puppet 5 too.

edit flag offensive delete link more

Comments

Hi Jorhett, Check the tree output (init.pp...)

stivesso gravatar imagestivesso ( 2017-12-04 09:22:01 -0600 )edit

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

Stats

Asked: 2017-11-28 11:44:19 -0600

Seen: 87 times

Last updated: Dec 08