Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
LEARNING PUPPET

You're reading from   LEARNING PUPPET Build intelligent software stacks with the Puppet configuration management suite

Arrow left icon
Product type Paperback
Published in Aug 2015
Publisher
ISBN-13 9781784399832
Length 304 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Toc

Table of Contents (12) Chapters Close

Preface 1. Puppet Development in Isolation FREE CHAPTER 2. Managing Packages in Puppet 3. My First Puppet Module 4. Monitoring Your Web Server 5. Load Balancing the Cluster 6. Scaling Up the Puppet Environment 7. Making the Configuration Dynamic 8. Extending Puppet 9. The Puppet Enterprise Console 10. Troubleshooting Puppet Index

Creating custom facts


So far, in this book, we have been using Puppet's built-in facts, such as the ipaddress_eth1 and uptime. In comparison to functions, facts are much easier to use as they don't accept arguments. We just reference them like we reference any Puppet variable using the $fact_name or $::fact_name syntax. Personally, I like to use the $::fact_name syntax because it clearly defines the scope of the variable. This is also the syntax recommended in the Puppet Language Style Guide (https://docs.puppetlabs.com/guides/style_guide.html). The $:: prefix in Puppet variables means that the variable scope is global ($::fact_name) as opposed to local ($fact_name). Although Puppet doesn't allow you to declare a local variable with the same name as a fact, it is a good practice to include the scope prefix ($::) when referencing facts. When someone is studying a manifest that I've written, they can easily see from the $:: prefix that the variable is referencing the fact rather than the local...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image