Dear all I have a module spacewalk with a custom fact to define if the server has been registered to spacewalk. The module should only run on RedHat server class profiles::base { ... case $::osfamily { redhat:{ include spacewalk include logrotate include postfix } solaris:{ include sendmail } default:{ fail("Unsupported platform: ${::osfamily}") } } } but the fact of the module spacewalk is run on Solaris. bash-3.00# /opt/csw/bin/facter osfamily Solaris bash-3.00# /opt/csw/bin/puppet agent --test Info: Retrieving plugin Notice: /File[/var/opt/csw/puppet/lib/facter/spacewalk.rb]/ensure: defined content as ''{md5}9aea0fbd79bc329b3685b7cfd22a5809'' I have another custom fact that should only run on certain server but it is installed on every server. Can you please help me? Are facts always installed on every server even if the module of the fact in only installed on certain server? Best regards, Andreas -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/95b66593-0ff9-4ffe-b54c-963bb84f7010%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Jeff Bachtel
2013-Dec-18 15:34 UTC
Re: [Puppet Users] custom fact should not run on Solaris
Facts are autoloaded from all modules and distributed to all agents, because that step occurs before the DSL is parsed for manifests (as it should be, because the DSL can be (is) impacted by facts). It is up to the custom fact to case itself out of execution for certain operating systems. For instance, from the postgresql pupmod comes this snippet from the customer fact about default versions: Facter.add("postgres_default_version") do setcode do result case Facter.value(''osfamily'') when ''RedHat'' get_redhatfamily_postgres_version() when ''Linux'' get_redhatfamily_postgres_version() when ''Debian'' get_debianfamily_postgres_version() else nil end Jeff On 12/18/2013 09:29 AM, Andreas Dvorak wrote:> Dear all > > I have a module spacewalk with a custom fact to define if the server > has been registered to spacewalk. > The module should only run on RedHat server > > class profiles::base { > ... > case $::osfamily { > redhat:{ > include spacewalk > include logrotate > include postfix > } > solaris:{ > include sendmail > } > default:{ > fail("Unsupported platform: ${::osfamily}") > } > } > } > > but the fact of the module spacewalk is run on Solaris. > bash-3.00# /opt/csw/bin/facter osfamily > Solaris > bash-3.00# /opt/csw/bin/puppet agent --test > Info: Retrieving plugin > Notice: /File[/var/opt/csw/puppet/lib/facter/spacewalk.rb]/ensure: > defined content as ''{md5}9aea0fbd79bc329b3685b7cfd22a5809'' > > I have another custom fact that should only run on certain server but > it is installed on every server. > Can you please help me? > Are facts always installed on every server even if the module of the > fact in only installed on certain server? > > Best regards, > Andreas > -- > You received this message because you are subscribed to the Google > Groups "Puppet Users" group. > To unsubscribe from this group and stop receiving emails from it, send > an email to puppet-users+unsubscribe@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/puppet-users/95b66593-0ff9-4ffe-b54c-963bb84f7010%40googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out.-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/52B1C08F.80800%40bericotechnologies.com. For more options, visit https://groups.google.com/groups/opt_out.
Felix Frank
2013-Dec-18 15:40 UTC
Re: [Puppet Users] custom fact should not run on Solaris
Yes, exactly, but this begs the question: Am I out of date for adding confine :operatingsystem => %w{Debian SLES OpenSUSE CentOS} outside the setcode block? Thanks, Felix On 12/18/2013 04:34 PM, Jeff Bachtel wrote:> Facts are autoloaded from all modules and distributed to all agents, > because that step occurs before the DSL is parsed for manifests (as it > should be, because the DSL can be (is) impacted by facts). > > It is up to the custom fact to case itself out of execution for certain > operating systems. For instance, from the postgresql pupmod comes this > snippet from the customer fact about default versions: > > Facter.add("postgres_default_version") do > setcode do > result > case Facter.value(''osfamily'') > when ''RedHat'' > get_redhatfamily_postgres_version() > when ''Linux'' > get_redhatfamily_postgres_version() > when ''Debian'' > get_debianfamily_postgres_version() > else > nil > end > > Jeff-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/52B1C1DF.6010608%40alumni.tu-berlin.de. For more options, visit https://groups.google.com/groups/opt_out.
Jeff Bachtel
2013-Dec-18 17:35 UTC
Re: [Puppet Users] custom fact should not run on Solaris
I think that pattern''s still good. Possibly that''s the difference between a nil fact being set and the fact being missing, however. Jeff On 12/18/2013 10:40 AM, Felix Frank wrote:> Yes, exactly, but this begs the question: Am I out of date for adding > > confine :operatingsystem => %w{Debian SLES OpenSUSE CentOS} > > outside the setcode block? > > Thanks, > Felix > > On 12/18/2013 04:34 PM, Jeff Bachtel wrote: >> Facts are autoloaded from all modules and distributed to all agents, >> because that step occurs before the DSL is parsed for manifests (as it >> should be, because the DSL can be (is) impacted by facts). >> >> It is up to the custom fact to case itself out of execution for certain >> operating systems. For instance, from the postgresql pupmod comes this >> snippet from the customer fact about default versions: >> >> Facter.add("postgres_default_version") do >> setcode do >> result >> case Facter.value(''osfamily'') >> when ''RedHat'' >> get_redhatfamily_postgres_version() >> when ''Linux'' >> get_redhatfamily_postgres_version() >> when ''Debian'' >> get_debianfamily_postgres_version() >> else >> nil >> end >> >> Jeff-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/52B1DCF4.50000%40bericotechnologies.com. For more options, visit https://groups.google.com/groups/opt_out.