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
Operating system
Memory size
Architecture
Processor count
Note
To see a complete list of the facts available on your system, run:
ubuntu@cookbook:~/puppet$ sudo facter architecture => amd64 augeasversion => 0.10.0 domain => compute-1.internal ec2_ami_id => ami-137bcf7a ec2_ami_launch_index => 0 ...
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.
How to do it…
Here's an example of using Facter facts in a manifest.
Reference a Facter fact in your manifest like any other variable. Facts are global variables in Puppet, so should be prefixed with a double colon (
::
), as in the following code snippet...