To check the syntax of your manifest file:

 puppet parser validate init.pp

To check for errors:

 # cd /etc/puppet/environments/unix_non_prod/modules
 
 # puppet apply testmodule/tests/init.pp --noop
 Error: Could not find class testmodule for mytestserver.daengkhao.com on node mytestserver.daengkhao.com
 Error: Could not find class testmodule for mytestserver.daengkhao.com on node mytestserver.daengkhao.com

Strange, the command can't find the class, but it's there:

 # pwd
 /etc/puppet/environments/unix_test/modules
 # ls
 testmodule

And the location is in the modulepath:

 # puppet config print modulepath --section master --environment unix_test
 /etc/puppet/environments/unix_test/modules:/etc/puppet/environments/unix_test/modules:/etc/puppet/environments/common:/etc/puppet/modules:/usr/share/puppet/modules

But, I forgot, when you run “puppet apply” you are effectively running the puppet agent and that will use the environment as set in /etc/puppet/puppet.conf

 # cat /etc/puppet/puppet.conf
 ......
 ......
 [agent]
     # The file in which puppetd stores a list of the classes
     # associated with the retrieved configuration.  Can be loaded in
     # the separate ``puppet`` executable using the ``--loadclasses``
     # option.
     # The default value is '$statedir/classes.txt'.
     classfile = $statedir/classes.txt
 
     # Where puppetd caches the local configuration.  An
     # extension indicating the cache format is added automatically.
     # The default value is '$confdir/localconfig'.
     localconfig = $vardir/localconfig
 
     # Disable the default schedules as they cause continual skipped
     # resources to be displayed in Foreman - only for Puppet >= 3.4
     default_schedules = false
 
     report            = true
     pluginsync        = true
     masterport        = 8140
     environment       = production
 ......
 ......

So it is searching for my class in the production environment not unix_test. So rerun with modulepath set:

 # puppet apply testmodule/tests/init.pp --modulepath=/etc/puppet/environments/unix_test/modules --noop
 Notice: Compiled catalog for mytestserver.daengkhao.com in environment production in 0.13 seconds
 Notice: /Stage[main]/testmodule/Cron[testmodule]/ensure: current_value absent, should be present (noop)
 Error: /Stage[main]/testmodule/File[/admin/testmodule]: Could not evaluate: Could not retrieve information from environment production source(s)    puppet:///modules/unix_test
 Notice: Class[testmodule]: Would have triggered 'refresh' from 1 events
 Notice: Stage[main]: Would have triggered 'refresh' from 1 events
 Notice: Finished catalog run in 0.33 seconds

Works but found an error. It can't find the files associated with the class. A quick change from:

 source => "puppet:///modules/unix_test",

to the correct location:

 source => "puppet:///modules/testmodule",

Run again:

 # puppet apply testmodule/tests/init.pp --modulepath=/etc/puppet/environments/unix_test/modules --noop
 Notice: Compiled catalog for mytestserver.daengkhao.com in environment production in 0.14 seconds
 Notice: /Stage[main]/testmodule/Cron[testmodule]/ensure: current_value absent, should be present (noop)
 Notice: /Stage[main]/testmodule/File[/admin/testmodule]/ensure: current_value absent, should be directory (noop)
 Notice: Class[testmodule]: Would have triggered 'refresh' from 2 events
 Notice: Stage[main]: Would have triggered 'refresh' from 1 events
 Notice: Finished catalog run in 0.21 seconds

Success.

You can also check from the site.pp level

 root@xgb00uinfapp01p manifests]# puppet apply site.pp --modulepath=/etc/puppet/environments/unix_non_prod/modules --debug --noop
 Debug: Runtime environment: puppet_version=3.8.6, ruby_version=2.0.0, run_mode=user, default_encoding=UTF-8
 Debug: Evicting cache entry for environment 'production'
 Debug: Caching environment 'production' (ttl = 0 sec)
 Debug: Evicting cache entry for environment 'production'
 Debug: Caching environment 'production' (ttl = 0 sec)
 Debug: Loading external facts from /var/lib/puppet/facts.d
 Debug: Evicting cache entry for environment 'production'
 Debug: Caching environment 'production' (ttl = 0 sec)
 Debug: importing '/etc/puppet/environments/unix_non_prod/manifests/nodes.pp' in environment production
 Notice: Compiled catalog for xgb00uinfapp01p.newco.global in environment production in 0.01 seconds
 ....
 ....

Recent Changes