Go to main content

Using Puppet to Perform Configuration Management in Oracle® Solaris 11.4

Exit Print View

Updated: October 2019
 
 

Writing Puppet Manifests That Specify Node-Specific Code

If you are managing configuration for a variety of systems, you might consider specifying conditional logic in your manifests, which ensures that each system is correctly matched to the appropriate configuration.

To enforce this logic, use the node keyword in your site manifest (which can be a single file with a .pp file extension or a directory containing several files with a .pp file extension). While node declarations enable you to specify any arbitrary Puppet code, it is recommended that they only contain variable assignments and class declarations.

The following example shows how you would match identical configuration for two nodes, agent1.company.com and agent2.company.com:

node ‘agent1.company.com’, ‘agent2.company.com’ {
   # Include resources here
}

The following example shows the syntax that you would use to match identical configuration for two nodes, along with a different resource definition for a third node (agent3.company.com).

node 'agent1.company.com', 'agent2.company.com' {

  # Include resources here
}
node 'agent3.company.com' {

  # Include other resources here

}

Puppet also provides a special node, called default, which enables a fallback configuration for any of the nodes that do not match existing node definitions. You would define a fallback configuration for these nodes as follows:

node default {
  # Include other resources here
}

For more in-depth information about writing manifests that includes node-specific code, go to https://puppet.com/docs/puppet/5.5/lang_classes.html.