Chapter 9. Wrap-Up of Puppet Basics

In this part, you’ve created a safe, risk-free learning environment you can utilize to write and test Puppet manifests. You’ve learned the following things about Puppet:

  • Puppet policies are written in manifests.
  • Manifests contain one or more resource declarations.
  • Resources create, alter, or remove their types: user, group, file, and so on.
  • Facter provides data about the node useful for local customization.

You have learned each part of the Puppet configuration language and how to utilize it to create manifests. You’ve used Puppet to apply the manifest on your test system. puppet apply does the following:

  • Parses a manifest file and reports any errors.
  • Utilizes facts about the system as variables for customization.
  • Executes immediately on the local system.
  • Provides verbose output informing you of what it has done.
Tip
While many people utilize puppet apply only for testing manifest changes, it can be used at broad scale if a method of synchronizing manifests to each node is available. We’ll discuss the pros and cons of this approach in Part IV.

Best Practices for Writing Manifests

Before moving on to the next chapter, I’d like to remind you of best practices for writing Puppet manifests:

  • Quote all unquoted string values.
  • ensure should be the first attribute in a resource block.
  • Align the arrows for attributes within a resource block.
  • Enable the strict_variables configuration setting to catch errors while testing.
  • Group resources by their relationship with each other.
  • Don’t use conditionals within resource declarations.
  • Provide defaults for case and select statements.
  • When something can be done multiple ways, always use the most readable option.

You can find the Puppet Style Guide at https://docs.puppetlabs.com/guides/style_guide.html. All of the examples in this book have been compliant with the style guide.

Learning More About Puppet Manifests

To expand on what you have learned in this chapter, investigate the built-in resource types provided by Puppet. There are more than we have discussed in this chapter, and you’ll find many of them immediately useful. Here are just a few we didn’t mention previously:

augeas A programatic API for managing configuration files
cron Cron scheduler entries
host Host file entries
interface Networking
mailalias Mail aliases
mount Filesystem mount points
nagios_* Types to manage Nagios host, service, contact entries
router Manages a connected router
sshkey SSH key management
yumrepo Package repository

The complete list of built-in resource types can be found at “Resource Type Reference” on the Puppet docs site.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset