Skip to content

Instantly share code, notes, and snippets.

@vchepkov
Last active June 14, 2024 17:48
Show Gist options
  • Save vchepkov/92e0719fbb610c8905a5351b44c8588f to your computer and use it in GitHub Desktop.
Save vchepkov/92e0719fbb610c8905a5351b44c8588f to your computer and use it in GitHub Desktop.
class puppet_bootstrap::facter (
Optional[Array[String]] $blocklist = undef,
Optional[Array[String]] $cachelist = undef,
String $cache_ttl = '1 day',
) {
# individual facts can only be blocklisted in puppet 7
if versioncmp(fact('aio_agent_version'),'7') >= 0 {
file { '/etc/puppetlabs/facter':
ensure => directory,
}
Hocon_setting {
path => '/etc/puppetlabs/facter/facter.conf',
require => File['/etc/puppetlabs/facter'],
}
if $blocklist {
hocon_setting { 'blocklist facts group':
ensure => present,
setting => 'fact-groups.blocked-facts',
value => $blocklist,
type => 'array',
}
-> hocon_setting { 'blocklist facts':
ensure => present,
setting => 'facts.blocklist',
value => ['blocked-facts'],
type => 'array',
}
} else {
hocon_setting { 'blocklist facts group':
ensure => absent,
setting => 'fact-groups.blocked-facts',
}
hocon_setting { 'blocklist facts':
ensure => absent,
setting => 'facts.blocklist',
}
}
if $cachelist {
hocon_setting { 'cachelist facts group':
ensure => present,
setting => 'fact-groups.cached-facts',
value => $cachelist,
type => 'array',
}
-> hocon_setting { 'cachelist facts':
ensure => present,
setting => 'facts.ttls',
value => [{'cached-facts' => $cache_ttl }],
type => 'array',
}
} else {
hocon_setting { 'cachelist facts group':
ensure => absent,
setting => 'fact-groups.cached-facts',
}
hocon_setting { 'cachelist facts':
ensure => absent,
setting => 'facts.ttls',
}
}
}
}
@vchepkov
Copy link
Author

puppet_bootstrap::facter::blocklist:
  - kmods
  - mountpoints
  - udev
puppet_bootstrap::facter::cachelist:
  - yum_updates
  - yum_has_updates
  - yum_package_updates
  - yum_reboot_required

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment