The init.pp and site.pp Files

Length: 00:06:12

Lesson Summary:

We now want to create our init.pp. This is what gets called when we reference just the nginx module itself, and all modules must have an init.pp file.

# pdk new class nginx
# vim manifests/init.pp

We're going to use this file to reference all of our classes, so that when we call the nginx module, all tasks are complete. Since we only have our nginx::install class right now, we'll start with that.

The contain function ensures that our classes are performed in the correct order, making sure the contained class is not run prior to the manifest (in this instance, the init.pp), but is finished before the manifest is complete.

class nginx {
  contain nginx::install
}

Save and exit this init.pp fie.

We can now map our nginx module to our agent node, allowing us to apply it. This is done in the production environment's site.pp file, which is the default manifest name. All we have to do is define our node, then include our module:

node AGENTSERVER.mylabserver.com {
  include nginx::install
}

Save and exit the file.

We can now make sure our module works by logging in to our CentOS 7 agent node, becoming root, and running:

# puppet agent -t

Then too confirm that nginx was installed, run:

# which nginx


This lesson is only available to Linux Academy members.

Sign Up To View This Lesson
Or Log In

Looking For Team Training?

Learn More