Disabling Legacy Facts in Puppet 8

317 görüntüleme
İlk okunmamış mesaja atla

Josh Cooper

okunmadı,
21 Eki 2022 14:54:1021.10.2022
alıcı Puppet Developers
Hi all,

With Puppet 8 coming, I'd like to map out what's required to disable legacy facts by default.

First some context, legacy facts are flat key=value pairs and originally that's how Facter reported facts. In Facter 3.5, we added support for structured data (hash/array). For compatibility reasons, we've been reporting both legacy and structured facts, e.g. "osfamily"="Debian" and {"os" => { "family" => "Debian" }}. This way manifests that reference legacy facts continue to compile.

So why do we care about disabling legacy facts?
  1. Facter automatically creates multiple legacy facts for each block device, network interface or processor.
  2. Puppetserver adds each top-level variable (including legacy facts) to the scope object used to render ERB templates. This can have a significant impact on compiler performance (PUP-9577)
  3. Legacy facts duplicate information in structured facts and we're sending it to puppetserver & puppetdb.
It's possible to block all legacy facts in facter.conf:

facts : {
  blocklist : [ "legacy" ],
}

However, this breaks Puppet, because its builtin providers rely on legacy facts, for example, the init provider relies on the legacy "operatingsystem" fact and will fail if the legacy fact is missing (PUP-10853)

$ puppet apply -e 'notify { "foo": }'
Error: Could not autoload puppet/provider/service/init: undefined method `downcase' for nil:NilClass

The alternative is to define a new fact group and add specific legacy facts to it, for example to block processors and network interfaces. 

facts : {
    blocklist : [ "my-legacy-facts" ],
}
fact-groups : {
    my-legacy-facts : [ "^(ipaddress6?|mtu|netmask6?|network6?|scope6?)(_.*)?" ]
}

However, Facter 4 slows down as the size of the block list grows (FACT-3161FACT-3080).

For Puppet 7.x, I'd like to:
  1. Add a configuration setting "include_legacy_facts" so Puppet can opt-into not sending legacy facts to puppetserver (PUP-11662) In a default agent configuration, this results in 25% less fact data. This is safe so long as legacy facts are not used during compilation (manifests, hiera configuration & data sources). There's already a legacy_facts puppet-lint plugin to help users migrate.
  2. Provider confining/suitability won't be affected because "Facter.value(<legacy>)" will still resolve legacy facts on the agent.
  3. Fix the block list slowness
For Puppet 8.0, I'd like to:
  1. Change the default value of "include_legacy_facts" to false (PUP-11430)
  2. Change Puppet's builtin type/providers to only reference structured facts (PUP-8543). I think this is only safe to do in Puppet 8, because of the way modules use rspec-puppet & rspec-puppet-facts to stub provider suitability.
Josh
Tümünü yanıtla
Yazarı yanıtla
Yönlendir
0 yeni ileti