Book Image

Puppet Cookbook - Third Edition

Book Image

Puppet Cookbook - Third Edition

Overview of this book

Table of Contents (17 chapters)
Puppet Cookbook Third Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Getting information about the environment


Often in a Puppet manifest, you need to know some local information about the machine you're on. Facter is the tool that accompanies Puppet to provide a standard way of getting information (facts) from the environment about things such as these:

  • Operating system

  • Memory size

  • Architecture

  • Processor count

To see a complete list of the facts available on your system, run:

$ sudo facter
architecture => amd64
augeasversion => 0.10.0
domain => compute-1.internal
ec2_ami_id => ami-137bcf7a
ec2_ami_launch_index => 0

Note

While it can be handy to get this information from the command line, the real power of Facter lies in being able to access these facts in your Puppet manifests.

Some modules define their own facts; to see any facts that have been defined locally, add the -p (pluginsync) option to facter as follows:

$ sudo facter -p

How to do it…

Here's an example of using Facter facts in a manifest:

  1. Reference a Facter fact in your manifest like any...