I have written a custom puppet fact using a ruby script. It is very simple - it just adds a string to a fact. However I have written a module but it appears to me that the custom fact has been applied to all my machines without me specifying any node definitions. When I run a puppet agent --test --noop, I see the custom fact appear in /var/lib/puppet/lib/facter. Info: Loading facts in /var/lib/puppet/lib/facter/addfacter.rb I checked my nodes by running facter and it doesn''t appear, unless I run facter -p I only want my custom fact to run on a specific node via a definition My question is, do custom facts scripts run by default regardless of any node definitions? If not, what am I doing wrong? Many thanks - Oli -- 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 post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Facts automatically get distributed to all nodes with pluginsync. You need to write them in such a way that they will only create the fact on the nodes that need it. Stefan - Zipkid - Goethals On Mon, Mar 11, 2013 at 1:31 PM, vioilly <oliverleach@gmail.com> wrote:> I have written a custom puppet fact using a ruby script. It is very simple > - it just adds a string to a fact. However I have written a module but it > appears to me that the custom fact has been applied to all my machines > without me specifying any node definitions. When I run a puppet agent > --test --noop, I see the custom fact appear in /var/lib/puppet/lib/facter. > > Info: Loading facts in /var/lib/puppet/lib/facter/addfacter.rb > > I checked my nodes by running facter and it doesn''t appear, unless I run > facter -p > > I only want my custom fact to run on a specific node via a definition > > > My question is, do custom facts scripts run by default regardless of any > node definitions? If not, what am I doing wrong? > > > Many thanks - Oli > > > -- > 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 post to this group, send email to puppet-users@googlegroups.com. > Visit this group at http://groups.google.com/group/puppet-users?hl=en. > 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 post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
You can also use the puppetlabs stdlib module which provides an easy ad-hoc way of defining arbitrary facts on a system using text files in /etc/facter/facts.d/ more info: https://puppetlabs.com/blog/module-of-the-week-puppetlabsstdlib-puppetlabs-standard-library-part-3 Many facts are best discovered pragmatically, but something are just arbitrary which is where you want soemthing like this. For example we have custom facts that pragmatically how the serial console of a server should be setup based on what hardware and connections are discovered, but use facts.d on workstatons we mange so users can self select a la cart configurations suchas if they want NFS automounted and certain other optional configuration packages. -Jon On Mon, Mar 11, 2013 at 9:43 AM, Stefan Goethals <stefan@zipkid.eu> wrote:> Facts automatically get distributed to all nodes with pluginsync. > You need to write them in such a way that they will only create the fact on > the nodes that need it. > > Stefan - Zipkid - Goethals > > > On Mon, Mar 11, 2013 at 1:31 PM, vioilly <oliverleach@gmail.com> wrote: >> >> I have written a custom puppet fact using a ruby script. It is very simple >> - it just adds a string to a fact. However I have written a module but it >> appears to me that the custom fact has been applied to all my machines >> without me specifying any node definitions. When I run a puppet agent --test >> --noop, I see the custom fact appear in /var/lib/puppet/lib/facter. >> >> Info: Loading facts in /var/lib/puppet/lib/facter/addfacter.rb >> >> I checked my nodes by running facter and it doesn''t appear, unless I run >> facter -p >> >> I only want my custom fact to run on a specific node via a definition >> >> >> My question is, do custom facts scripts run by default regardless of any >> node definitions? If not, what am I doing wrong? >> >> >> Many thanks - Oli >> >> >> -- >> 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 post to this group, send email to puppet-users@googlegroups.com. >> Visit this group at http://groups.google.com/group/puppet-users?hl=en. >> 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 post to this group, send email to puppet-users@googlegroups.com. > Visit this group at http://groups.google.com/group/puppet-users?hl=en. > 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 post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
I''ve read up on this a bit more and I am now beginning to understand how custom facts work. It did surprise me actually that all custom facts get instantiated at runtime - I also understand that you can write your ruby scripts in a way that your custom facts scripts do not necessarily need to apply changes to your nodes. But this appears to be an overhead to me. Yes, I can work around it, but i would rather not have to have the overhead. Why is this designed this way? Reading this in detail helped me understand the issue http://docs.puppetlabs.com/guides/custom_facts.html Thanks for your reply. -Oli -- 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 post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.