Hello, I''m new to puppet and facter. Initially we are planning on using facter/puppet to inventory machines (Mac, Ubuntu, and RHEL). We plan on writing a number of custom facts. Obviouly some of the facts will only be specific to some OSs. I know there is a "confine" method, but it confuses me. It seems the confine statement in some of the recipes and in the Turnbull book is checked after most of the work is done. Take for example: if FileTest.exists?("/usr/sbin/dmidecode") # Add remove things to query here query = { ''BIOS Information'' => ''Vendor:'', ''System Information'' => [ ''Manufacturer:'', ''Product Name:'' , ''Serial Number:'', ''Version:'' ], ''Chassis Information'' => ''Type:'', ''Processor Information'' => [''Version:'', ''Max Speed:''], ''Memory Controller Information'' => [ ''Maximum Memory Module Size:'', ''Maximum Total Memory Size:'' ] } # Run dmidecode only once output=%x{/usr/sbin/dmidecode 2>/dev/null} query.each_pair do |key,v| v.each do |value| output.split("Handle").each do |line| if line =~ /#{key}/ and line =~ /#{value} (\w.*)\n*./ result = $1 Facter.add(value.chomp('':'')) do confine :kernel => :linux setcode do result end end end end end end end Does this code get executed in the kernel is not Linux, or is the fact just not added is the kernel is not linux? Also, should I bundle the facts into one document, say by platform, or should each fact be in its own file? Thanks, Allan Marcus --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
bump sorry, but someone has gotta know the answers to to these questions. I really appreciate your help. -Allan --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 4/26/2009 5:02 PM, Allan Marcus wrote:> Hello, > > I''m new to puppet and facter. Initially we are planning on using > facter/puppet to inventory machines (Mac, Ubuntu, and RHEL). We plan > on writing a number of custom facts. Obviouly some of the facts will > only be specific to some OSs. I know there is a "confine" method, but > it confuses me. It seems the confine statement in some of the recipes > and in the Turnbull book is checked after most of the work is done.http://reductivelabs.com/trac/puppet/wiki/Recipes/HostgroupFact , http://reductivelabs.com/trac/puppet/wiki/Recipes/RaidFact , and http://reductivelabs.com/trac/puppet/wiki/Recipes/InterfaceName , at least, put their confine statements very early.> Does this code get executed in the kernel is not Linux, or is the fact > just not added is the kernel is not linux?I think it''ll execute /usr/sbin/dmidecode as long as that file exists, and will add the fact as long as you''re running Linux.> Also, should I bundle the facts into one document, say by platform, or > should each fact be in its own file?All my facts are stored in separate files, but that''s mostly because my fact development tends to be pretty tightly-focused. Never needed to group them together. But I''d never separate them by platform, but just put the platform logic into the fact similar to what the InterfaceName recipe does. -- Mike Renfro / R&D Engineer, Center for Manufacturing Research, 931 372-3601 / Tennessee Technological University --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Fri, May 1, 2009 at 12:11 PM, Mike Renfro <renfro@tntech.edu> wrote:>> Also, should I bundle the facts into one document, say by platform, or >> should each fact be in its own file? > > All my facts are stored in separate files, but that''s mostly because my > fact development tends to be pretty tightly-focused. Never needed to > group them together. But I''d never separate them by platform, but just > put the platform logic into the fact similar to what the InterfaceName > recipe does.In the 0.24.x series, we find file serving is a large part of the load, and reducing the number of separate fact files reduced load. If you''re not experiencing load issues, there''s no reason why you have to bundle them together unless you''re sharing code amongst facts. -- Nigel Kersten nigelk@google.com System Administrator Google, Inc. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On May 1, 2009, at 1:11 PM, Mike Renfro wrote:> > On 4/26/2009 5:02 PM, Allan Marcus wrote: >> Hello, >> >> I''m new to puppet and facter. Initially we are planning on using >> facter/puppet to inventory machines (Mac, Ubuntu, and RHEL). We plan >> on writing a number of custom facts. Obviouly some of the facts will >> only be specific to some OSs. I know there is a "confine" method, but >> it confuses me. It seems the confine statement in some of the recipes >> and in the Turnbull book is checked after most of the work is done. > > http://reductivelabs.com/trac/puppet/wiki/Recipes/HostgroupFact , > http://reductivelabs.com/trac/puppet/wiki/Recipes/RaidFact , and > http://reductivelabs.com/trac/puppet/wiki/Recipes/InterfaceName , at > least, put their confine statements very early.OK, so in the samples you link to above, they all have the confine as the first line, then a setcode do block after the confine. Does the setcode do block get executed if the confine test fails? that would make sense to me, but I just want to be sure. Thanks, Allan --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Allan Marcus wrote:> OK, so in the samples you link to above, they all have the confine as > the first line, then a setcode do block after the confine. Does the > setcode do block get executed if the confine test fails? that would > make sense to me, but I just want to be sure.I''m pretty sure that''s correct. Looking at Facter 1.5.1''s operatinsystemrelease.rb, there are several stanzas like: Facter.add(:operatingsystemrelease) do confine :operatingsystem => :fedora setcode do File::open("/etc/fedora-release", "r") do |f| line = f.readline.chomp if line =~ /\(Rawhide\)$/ "Rawhide" elsif line =~ /release (\d+)/ $1 end end end end Given that I''d to find a /etc/fedora-release only on Fedora, and I see no other obvious error handling if that file doesn''t exist, I''m going to assume that the confine ensures that the setcode block only runs if the confine passes. -- Mike Renfro / R&D Engineer, Center for Manufacturing Research, 931 372-3601 / Tennessee Technological University -- renfro@tntech.edu --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---