From the course: Puppet Essential Training
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Custom facts - Puppet Tutorial
From the course: Puppet Essential Training
Custom facts
- [Instructor] Puppet supports the ability to add custom facts to your nodes. We'll look at a few examples. Customs facts are another advanced Puppet feature you'll commonly see in modules. Just like built-in facts like OS family or IP address, it's possible to create your own facts that interact with the agent node. Remember Puppet code itself runs on the master, so any data about the target system needs to be provided to the master via facts. In this lesson we'll look at some of the ways you can create and use custom facts in your own code. Adding a custom fact to your module is pretty simple. You just need to create a directory live/facter and then a .rb file with the same name as your fact. Inside of that file you'll need some Ruby code. Here's an example from the Puppet documentation. The first line adds a new facter called the hardware_platform and then opens a code block. Under that there's a setcode statement that begins another code block, and within that block we have our…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.