To enable legacy facts in Puppet, you set the include_legacy_facts
parameter to true
within your Puppet configuration.
Understanding Legacy Facts in Puppet
Legacy facts refer to older facter facts that were present in previous versions of Puppet and Facter. Over time, Facter evolved to provide structured data, deprecating many of these legacy facts in favor of more organized and predictable structured facts. However, older Puppet modules or custom code might still rely on these legacy facts. When migrating to newer Puppet versions, these modules might fail if the necessary legacy facts are not available.
How to Enable Legacy Facts
Re-enabling legacy facts primarily involves modifying the puppet.conf
configuration file. This instructs Facter to include the older facts alongside the modern structured facts.
1. Locate puppet.conf
The puppet.conf
file is Puppet's main configuration file. Its location varies slightly depending on your operating system and Puppet installation:
- Linux/Unix: Typically
/etc/puppetlabs/puppet/puppet.conf
- Windows: Typically
C:\ProgramData\PuppetLabs\puppet\etc\puppet.conf
2. Add the include_legacy_facts
Setting
Open your puppet.conf
file with a text editor and add the include_legacy_facts = true
line under the appropriate section, commonly [main]
or [agent]
. The [main]
section applies settings globally, while [agent]
specifically affects the Puppet agent.
Example Configuration (puppet.conf
):
# /etc/puppetlabs/puppet/puppet.conf
[main]
# Other global Puppet settings might be here
server = puppet.example.com
certname = %{::fqdn}
environment = production
include_legacy_facts = true
[agent]
# Other Puppet agent specific settings
runinterval = 30m
In this example, placing include_legacy_facts = true
under [main]
ensures that both the Puppet agent and any local Facter calls (if facter
is run on the node) will include legacy facts.
3. Restart Puppet Agent Service
After modifying puppet.conf
, you need to restart the Puppet agent service on the node for the changes to take effect.
- Linux (systemd):
sudo systemctl restart puppet
- Linux (SysVinit):
sudo service puppet restart
- Windows: Restart the "Puppet Agent" service via the Services Manager or PowerShell.
4. Verify Legacy Facts
You can verify that legacy facts are now available by running facter
on the command line of the node. If you previously had issues with modules relying on facts like ipaddress_eth0
(which is a legacy fact often replaced by networking.interfaces.eth0.ip
), running facter -p
(which evaluates Puppet-specific facts) should now display them.
Important Considerations
While enabling legacy facts can resolve immediate compatibility issues, it's crucial to understand the implications:
- Compatibility: This setting is primarily for backward compatibility with older modules that haven't been updated to use modern structured facts.
- Performance: Including a larger set of facts (legacy and modern) can slightly increase the time Facter takes to collect facts, though the impact is often negligible for most environments.
- Future-Proofing: It's generally recommended to update your Puppet code and modules to use structured facts where possible. This aligns with Puppet's modern architecture and reduces reliance on deprecated features.
- Migration Path: Use this as a temporary measure while you work on refactoring your code to utilize modern Facter outputs.
Overview of Configuration Parameter
Parameter Name | Value | Location | Purpose |
---|---|---|---|
include_legacy_facts |
true |
puppet.conf |
Instructs Facter to collect and expose older, deprecated facts for compatibility with legacy code. |
By carefully managing the include_legacy_facts
setting, you can ensure smooth transitions and compatibility for your Puppet infrastructure while planning for future updates.