BreadcrumbHomeResourcesBlog Puppet + Facter 4: Key Features You Need To Know February 3, 2021 Puppet + Facter 4: Key Features You Need to KnowHow to & Use CasesProducts & ServicesBy Bogdan IrimieWhat's the latest with Puppet and Facter? Find out in this blog.Table of Contents:What is Facter?How is Facter 4 Different?New Facter 4 FeaturesHow to Improve Testing With FacterGet Started With Facter 4What Is Facter?Facter is a cross-platform system profiling tool. It gathers nuggets of information about a system such as its hostname, IP address, and operating system.We call these nuggets of information facts and they are used by other Puppet products like Puppet, Puppet Server and Bolt to make decisions in their automation process. You can extend Facter by writing custom facts or external facts and use them in Puppet manifests.You’ll find this blog post useful when migrating from older versions of Puppet to Puppet 7. The new features allow a granular control and enable new use cases.How Is Facter 4 Different?Starting with Puppet 7, Facter 4 is the default version of Facter.Facter 4 is written in Ruby and provides many new capabilities that you didn’t have with Facter 3, including:Blocking and caching all types of facts at a granular levelUser-defined fact groupsCreating custom and external fact hierarchies using the dot notationProfiling using the --timing command line optionImproved module testingWe explore these in more detail below. Note that while we aimed for 100% API compatibility with Facter 3, there may still be some small inconsistencies. One known example would be facter -p which was dropped in favor of puppet facts show. For more details, you can have a look over our release notes.New Facter 4 FeaturesBlocking and Caching Any FactFacter 4 allows blocking and caching any type of fact at a granular level. For example, if you block the memory fact, you won’t get any memory facts, but if you block the memory.swap fact, you will still get memory.system facts. The best part about the new blocking and caching mechanism is that you can go as deep as you want in the facts hierarchy — you can even block only the memory.swap.available fact.memory fact example:{ ... "memory": { "swap": { "available": "1.36 GiB", "available_bytes": 1465647104, "capacity": "72.70%", "encrypted": true, "total": "5.00 GiB", "total_bytes": 5368709120, "used": "3.64 GiB", "used_bytes": 3903062016 }, "system": { "available": "91.19 MiB", "available_bytes": 95621120, "capacity": "99.72%", "total": "32.00 GiB", "total_bytes": 34359738368, "used": "31.91 GiB", "used_bytes": 34264117248 } }, ... }memory.swap blocked example:{ ... "memory": { "system": { "available": "91.19 MiB", "available_bytes": 95621120, "capacity": "99.72%", "total": "32.00 GiB", "total_bytes": 34359738368, "used": "31.91 GiB", "used_bytes": 34264117248 } }, ... }To block and cache facts, and even groups of facts, use the blocklist and ttls attributes from facter.conf. In the example below, memory.swap is a fact and EC2 is a group consisting of two facts: ec2_metadata and ec2_userdata. The same principles apply for cached facts.facts : { blocklist : [ "memory.swap", "EC2" ] }Blocking and Caching GroupsAs we mentioned above, you can also block and cache groups of facts. Using the new fact-groups attribute in the facter.conf configuration file, you can place multiple facts in a group, and block or cache it. For example:facts : { blocklist : [ "my-group" ] } fact-groups : { my-group : ["memory.swap", "memory.system.available", "memory.system.available_bytes"] }Custom and External Facts HierarchyYou can arrange custom and external facts in hierarchical order using the . notation. Let's say you have the following two custom facts named my_organization.my_custom_fact1 and my_organization.my_custom_fact2. You can add an external fact named my_organization.my_external_fact, and the final output would be:my_organization => { my_custom_fact1 => "fact1_value", my_custom_fact2 => "fact2_value", my_external_fact => "external_fact_value" } Fact ProfilingFacter 4 revives the --time flag from Facter 2. Using this command line option, you can obtain benchmark information regarding facts.fact: memory.swap.available, took: 0.094675 seconds fact: memory.system.used_bytes, took: 0.100163 secondsHow to Improve Testing With FacterMany modules still run their tests with Facter 2 because Facter 3 was never released as a Ruby gem. This discrepancy between the way modules were tested and how they were actually being used allowed some bugs to get past CI pipelines. Facter 4 is released as a gem, so you can safely test your modules with the exact same Facter version that is used in production environments.Get Started With Facter 4For more details regarding Facter 4, you can have a look at our documentationOr check out video tutorials for the new features: structured custom facts, fact caching, fact blocking, and fact profiling.Not Using Puppet Enterprise Yet?Get more out of Facter and Puppet by trying Puppet Enterprise today.START MY TRIALLearn MoreExplore Puppet facts for WindowsDatadog + Puppet: How to send facts as tags for metrics and events