Last active
June 14, 2024 17:48
-
-
Save vchepkov/92e0719fbb610c8905a5351b44c8588f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | |
} | |
} | |
} | |
} |
Author
vchepkov
commented
Jun 14, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment