Puppet apply a local manifest or module

Sometimes we do not always need a puppet server and instead we can copy/install our puppet manifests or module to the local host. Using "puppet apply", applies a standalone Puppet manifest or module to to the local system. This assumes that we have puppet installed locally.

To apply a local manifest

$ puppet apply -l /tmp/manifest.log manifest.pp

If the manifest requires or references other modules then we need to state where to look for the modules as follows.

$ puppet apply -l /tmp/manifest.log --modulepath=/root/dev/modules  manifest.pp

Apply a module without a manifest

$ puppet apply -l /tmp/manifest.log --modulepath=/path/to/modules  -e "class {\"module_name\":}"

A Use Case:

I use a class called wwwjnvilocom which configures a CentOS server to host this website and I test on a vm.

I take the following steps to prepare the VM.

  • yum install puppet to install puppet
  • puppet module install jfryman-nginx #This installs the nginx module into /etc/puppet/modules
  • I then checkout my wwwjnvilocom module from my private git repo into /etc/puppet/modules

As a result, I can then just do

puppet apply --modulepath=/etc/puppet/modules -e 'class {"wwwjnvilocom":}'