André Fernandes
2012-Aug-15 09:28 UTC
[Puppet Users] facter: setting up module-specific custom facts?
I am customizing an existing puppet installation (with facter) and I think I ran into an issue understanding the scope of custom facts. I have several modules that are mapped exclusively to different classes of hosts within a nodes.pp file. What I''d like to achieve would be to have custom facts limited by module, for example hosts in module1would execute custom_fact_1 and hosts in module2 would only execute custom_fact_2. According to the facter/puppet docs, the custom facts go into a <module-name>/lib/facterdirectory, and are tied to that module. I have made it gather a few custom facts already, by adding the ruby scripts to a single module''slib/facter dir, but strangely they are not limiting themselves to the hosts to which the module is assigned. What is happening is that all custom facts are ran for all hosts (even the ones that don''t have any relationship to that module), which is not exactly what I intended. Did I misunderstand the documentation? Is this type of fact-module mapping possible? Note: I have achieved a similar behaviour by using confine instructions in the custom facts scripts, but this goes against the intended purpose, since I''d like to tie the custom facts to the modules themselves and not have the mapping in the scripts. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/k7nPCf2anxcJ. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Nan Liu
2012-Aug-15 16:38 UTC
Re: [Puppet Users] facter: setting up module-specific custom facts?
On Wed, Aug 15, 2012 at 2:28 AM, André Fernandes <andreezer@gmail.com> wrote:> I am customizing an existing puppet installation (with facter) and I think I > ran into an issue understanding the scope of custom facts. > > I have several modules that are mapped exclusively to different classes of > hosts within a nodes.pp file. What I''d like to achieve would be to have > custom facts limited by module, for example hosts in module1would execute > custom_fact_1 and hosts in module2 would only execute custom_fact_2. > > According to the facter/puppet docs, the custom facts go into a > <module-name>/lib/facterdirectory, and are tied to that module. > > I have made it gather a few custom facts already, by adding the ruby scripts > to a single module''slib/facter dir, but strangely they are not limiting > themselves to the hosts to which the module is assigned. What is happening > is that all custom facts are ran for all hosts (even the ones that don''t > have any relationship to that module), which is not exactly what I intended. > > Did I misunderstand the documentation? Is this type of fact-module mapping > possible? > > Note: I have achieved a similar behaviour by using confine instructions in > the custom facts scripts, but this goes against the intended purpose, since > I''d like to tie the custom facts to the modules themselves and not have the > mapping in the scripts.Pluginsync distributes all modules lib dir in modulepath to the client. It''s not based on whether a class in a module is assigned to the client. So yes custom facts get shipped to every system in that environment. Nan -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
jcbollinger
2012-Aug-16 13:20 UTC
Re: [Puppet Users] facter: setting up module-specific custom facts?
On Wednesday, August 15, 2012 11:38:47 AM UTC-5, Nan Liu wrote:> > > Pluginsync distributes all modules lib dir in modulepath to the > client. It''s not based on whether a class in a module is assigned to > the client. So yes custom facts get shipped to every system in that > environment. > >And it has to work that way, because Puppet cannot know which classes are assigned to a node until after it examines the node''s facts. You can write facts to be no-ops on nodes where you do not want them to run, and you can use the ''confine'' function inside custom fact implementations to make Facter use facts only on certain nodes. You cannot prevent all defined facts from being synced to every node, however, nor Facter executing the fact definition (but perhaps not evaluating it). John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/dR10VLVOYRQJ. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.