When we attempt to use a resource that is not available to our Puppet Master or Puppet environment, we can trigger a missing resource error, causing the catalog compilation to fail. While these are commonly caused by misspelling a resource type, they can also be caused by missing modules in an environment. In the following example, I'm attempting to use the NTP module with include ntp. Remember, classes are resources, too:
[root@wordpress puppet]# puppet agent -t
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Retrieving locales
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 wordpress (file: /etc/puppetlabs/code/environments/production/modules/profile/manifests/baseline.pp, line: 3, column: 3) on node wordpress
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
I'm simply missing the NTP class in my environment. I could resolve this by hand with puppet module install, but, if you're using r10k or Code Manager, enter the module entry and all of the dependencies into your environment Puppetfile:
mod 'puppetlabs/ntp'
mod 'puppetlabs/stdlib'
Using the Puppet module install method does make a module available to all environments, but I can only recommend using it on temporary Puppet Masters that are used to test code:
[root@pe-puppet-master manifests]# puppet module install puppetlabs/ntp
Notice: Preparing to install into /etc/puppetlabs/code/environments/production/modules ...
Notice: Downloading from https://forgeapi.puppet.com ...
Notice: Installing -- do not interrupt ...
/etc/puppetlabs/code/environments/production/modules
└─┬ puppetlabs-ntp (v7.2.0)
└── puppetlabs-stdlib (v4.25.1)