I was hoping to get some guidance on my first fact. I''d like to create a global configuration file that contains default values that I can reference in multiple classes. In other words, I''d like one source for, say, JAVA_HOME but I''d like to reference it in my java and profile classes. The configuration file would look like this: java_home=/usr/java/jdk1.5.0_15 jboss_home=/usr/local/jboss [etc] I''d like the fact to read the file and assign the value to a variable with the same name as the key, i.e., $java_home = "/usr/java/jdk1.5.0_15" $jboss_home = "/usr/local/jboss" [etc] Does anybody have a comparable example from which I can work? I''d really appreciate it. Cheers, Jeff --~--~---------~--~----~------------~-------~--~----~ 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 Sep 10, 8:27 am, Jeff <joesi...@gmail.com> wrote:> I was hoping to get some guidance on my first fact. I''d like to create > a global configuration file that contains default values that I can > reference in multiple classes. In other words, I''d like one source > for, say, JAVA_HOME but I''d like to reference it in my java and > profile classes. > > The configuration file would look like this: > > java_home=/usr/java/jdk1.5.0_15 > jboss_home=/usr/local/jboss > > [etc] > > I''d like the fact to read the file and assign the value to a variable > with the same name as the key, i.e., > > $java_home = "/usr/java/jdk1.5.0_15" > $jboss_home = "/usr/local/jboss" > > [etc] >Okay, I took a stab at this. Here''s my code: key = nil val = nil test = {} File.open("/var/puppet/modules/globals.conf").each do |line| key,val = line.split(/=/) if key != nil && val != nil test[key] = val key = nil val = nil end end test.each { |name,fact| Facter.add(name) do setcode do fact end end } Unfortunately, it doesn''t work. When I add print statements inside the test.each loop, I get values for ''name'' and ''fact'' HOWEVER, when I run it without those print statements I get nothing. I''m stumped. Jeff --~--~---------~--~----~------------~-------~--~----~ 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 Sep 10, 9:30 am, Jeff <joesi...@gmail.com> wrote:> On Sep 10, 8:27 am, Jeff <joesi...@gmail.com> wrote: > > > > > I was hoping to get some guidance on my first fact. I''d like to create > > a global configuration file that contains default values that I can > > reference in multiple classes. In other words, I''d like one source > > for, say, JAVA_HOME but I''d like to reference it in my java and > > profile classes. > > > The configuration file would look like this: > > > java_home=/usr/java/jdk1.5.0_15 > > jboss_home=/usr/local/jboss > > > [etc] > > > I''d like the fact to read the file and assign the value to a variable > > with the same name as the key, i.e., > > > $java_home = "/usr/java/jdk1.5.0_15" > > $jboss_home = "/usr/local/jboss" > > > [etc] > > Okay, I took a stab at this. Here''s my code: > > key = nil > val = nil > test = {} > File.open("/var/puppet/modules/globals.conf").each do |line| > key,val = line.split(/=/) > if key != nil && val != nil > test[key] = val > key = nil > val = nil > end > end > test.each { |name,fact| > Facter.add(name) do > setcode do > fact > end > end > > } > > Unfortunately, it doesn''t work. When I add print statements inside the > test.each loop, I get values for ''name'' and ''fact'' HOWEVER, when I run > it without those print statements I get nothing. I''m stumped. > > JeffThis is a scope issue: If I do this in my array iteration: test.each { |name,fact| Facter.add(name) do print name+"=>"+fact setcode do fact end end } name and fact print BUT if I do this: test.each { |name,fact| Facter.add(name) do setcode do print name+"=>"+fact fact end end } They do NOT print. Any ideas?? Jeff --~--~---------~--~----~------------~-------~--~----~ 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 Wed, Sep 10, 2008 at 05:27:58AM -0700, Jeff wrote:> I was hoping to get some guidance on my first fact. I''d like to create > a global configuration file that contains default values that I can > reference in multiple classes.Does this help? http://www.unixdaemon.net/facter_scripts/facterfiler.rb Dean -- Dean Wilson http://www.unixdaemon.net Profanity is the one language all programmers understand --- Anon --~--~---------~--~----~------------~-------~--~----~ 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 Sep 10, 11:48 am, Dean Wilson <dwil...@unixdaemon.net> wrote:> On Wed, Sep 10, 2008 at 05:27:58AM -0700, Jeff wrote: > > I was hoping to get some guidance on my first fact. I''d like to create > > a global configuration file that contains default values that I can > > reference in multiple classes. > > Does this help? > > http://www.unixdaemon.net/facter_scripts/facterfiler.rb >Dean, I suppose it kind of helps. This script fails in the same way that mine does. The variable ''value'' in the setcode block has no value. If I check it with a print statement prior to the setcode block, it prints a value. What version of facter are you running? Jeff --~--~---------~--~----~------------~-------~--~----~ 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 Sep 10, 1:26 pm, Jeff <joesi...@gmail.com> wrote:> On Sep 10, 11:48 am, Dean Wilson <dwil...@unixdaemon.net> wrote: > > > On Wed, Sep 10, 2008 at 05:27:58AM -0700, Jeff wrote: > > > I was hoping to get some guidance on my first fact. I''d like to create > > > a global configuration file that contains default values that I can > > > reference in multiple classes. > > > Does this help? > > >http://www.unixdaemon.net/facter_scripts/facterfiler.rb > > Dean, > > I suppose it kind of helps. This script fails in the same way that > mine does. The variable ''value'' in the setcode block has no value. If > I check it with a print statement prior to the setcode block, it > prints a value. What version of facter are you running? >This does not correspond with the book but I got to work. If I have a key named "haha" and I try to run "facter haha", I get nothing back. However, if I just run "facter" then I get all the information including the key value pairs in my config file. This leads me to my next problem. I''m not syncing facts. Here''s the error: debug: /puppetconfig/puppet/File[/var/puppet/facts]: Autorequiring File[/var/puppet] info: Retrieving facts err: /fact_collector/File[/var/puppet/facts]: Failed to generate additional resources during transaction: Cannot access mount[facts] err: /fact_collector/File[/var/puppet/facts]/source: Could not describe /facts: Cannot access mount[facts] info: /fact_collector/File[/var/puppet/facts]/source: No specified sources exist debug: /fact_collector/File[/var/puppet/facts]: Changing checksum debug: /fact_collector/File[/var/puppet/facts]: 1 change(s) debug: /fact_collector/File[/var/puppet/facts]/checksum: setting time (currently {time}Wed Sep 10 14:28:03 -0400 2008) debug: /fact_collector/File[/var/puppet/facts]/checksum: Replacing / var/puppet/facts checksum {time}Wed Sep 10 14:27:55 -0400 2008 with {time}Wed Sep 10 14:28:03 -0400 2008 notice: /fact_collector/File[/var/puppet/facts]/checksum: checksum changed ''{time}Wed Sep 10 14:27:55 -0400 2008'' to ''{time}Wed Sep 10 14:28:03 -0400 2008'' Any thoughts? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---