|| at Aug 22, 2012 at 6:13 pm
The slowdown comes from the command that I run before any Facter.add
statements. It takes roughly 1.5 seconds to run and I would need to run it
roughly 64 times if I had it in each Facter.add. Many facts are generated
by a loop that contains a Facter.add, so I feel like some sort of exception
would make things easier. I'd like to avoid using a "giant if statement"
if possible (there are roughly 100 lines of code that would be
encapsulated). One of the main issues I have is that there are two
different checks that happen in different parts of the code. I recognize
that some may consider adding more if-statements as increased readability,
but I feel like the added indentation for large chunks of code causes
confusion for readers (especially when looking at loops).
Thanks so much for your reply!
On Wednesday, August 22, 2012 11:36:13 AM UTC-5, Nigel Kersten wrote:
I have a script in $FACTERLIB that queries proprietary vendor tools for RAID
configuration. These tools are quite slow, so the top of my .rb file calls
the program once and stores the output in a variable. Multiple
statements then populate the facts. I would like to bail on this custom fact
script if it's being run on a VM or unsupported host. I don't think
"confine" would work here since I have multiple Facter.add and I would
ideally like to bail before it gets to any of them. If I try "exit," facter
just exists and no other facts are collected. Looking at the code in
facter/util/loader.rb, I could throw a ScriptError exception - but that
Anyone have experience or suggestions for doing something similar? I've
tried searching existing code with no luck.
You can surround the Facter.add calls with explicit checks like:
if Facter.value(:kernel) == "Darwin"
Facter::Util::Macosx.hardware_overview.each do |fact, value|
confine :kernel => :darwin
(Yes, that confine there is somewhat redundant...)
Are you really seeing a significant slowdown though if you don't do
this and simply have the confine call within each Facter.add ? If so,
we should work on that.
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/-/K5Mm3du3mkQJ.
To post to this group, send email to firstname.lastname@example.org.
To unsubscribe from this group, send email to email@example.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.