Think I've sorted it actually... Did this: =================================================================== --- lib/facter/oracle_clones.rb (revision 96307) +++ lib/facter/oracle_clones.rb (working copy) @@ -9,7 +9,7 @@ Facter.add("clone_#{db}") do setcode { # Look for a mount point, or set to nothing. - Facter::Util::Resolution.exec("grep #{db} /etc/fstab | awk {'print $1'}") or '' + Facter::Util::Resolution.exec("grep #{db.chomp} /etc/fstab | awk {'print $1'}") or '' } end end
Now to see how reliable it is :D Cheers Gav On Wednesday, 13 March 2013 12:53:37 UTC, Gavin Williams wrote: > > John > > I've updated to use the new fact, however I'm getting some intermittent > hanging issues when Puppet agent is loading facts... > > Tracked it down to the below fact, and specifically it looks like a '\n' > is creeping into the db var, which is causing the grep exec to hang :( > > Put in some additional logging, and got this output: > > Starting fact test script... > Running_dbs = > "SWREPC01\nSWPROD01" > Running dbs isnt nil... > Lines = > ["SWREPC01\n"] > Got a REPC database... "SWREPC01\n" > Command = /bin/grep SWREPC01 > /etc/fstab > > What I'm struggling with is how to remove the \n character easily as part > of the existing code... :s > > Any ideas??? > > Cheers > Gavin > > On Monday, 11 March 2013 14:44:54 UTC, jcbollinger wrote: >> >> >> >> On Friday, March 8, 2013 9:43:30 AM UTC-6, Gavin Williams wrote: >>> >>> Hmm, it seems that the new fact has broken my Network devices?! :( >>> >>> Getting the following when trying to run puppet against a network device: >>> $ sudo puppet device --deviceconfig devices/act-star-nactl01.conf -v >>> Info: starting applying configuration to act-star-nactl01 at >>> act-star-nactl01 >>> Info: Retrieving plugin >>> Info: Caching catalog for act-star-nactl01 >>> Error: Failed to apply catalog: undefined method `each' for nil:NilClass >>> >>> However I've got a catch in the fact which should stop it trying to do >>> 'each' on a nil class... >>> Adding '--trace' to the run gives me: >>> $ sudo puppet device --deviceconfig devices/act-star-nactl01.conf -v >>> --trace >>> Info: starting applying configuration to act-star-nactl01 at >>> act-star-nactl01 >>> Info: Retrieving plugin >>> Info: Caching catalog for act-star-nactl01 >>> Error: Failed to apply catalog: undefined method `each' for nil:NilClass >>> /var/lib/puppet/lib/facter/oracle_clones.rb:6 >>> /usr/lib/ruby/site_ruby/1.8/facter/util/loader.rb:81:in `load' >>> >> >> >> [...] >> >> >> >>> Any ideas??? >>> >>> >> >> That's weird. The code at that URL is broken, but it shouldn't have >> produced the trace you presented. Are you sure the trace and that version >> of the code go together? Anyway, here's how I might write it: >> >> # Get a list of running dbs... >> running_dbs = Facter::Util::Resolution.exec("ps -ef |grep [o]ra_pmon |awk >> {'print $8'} |awk 'BEGIN{FS=\"_\";} {print $3}'") >> >> # JCB: running_dbs will not be empty, but no problem if it were >> # JCB: must still watch out for nil, however >> unless running_dbs.nil? >> # JCB: must use lines() or each_line(), not each() >> running_dbs.lines.grep(/REPC/).each do |db| >> # Add fact >> Facter.add("clone_#{db}") do >> setcode { >> # JCB: prefer to put fact evaluation code into the setcode() block >> # The fact value is the export path >> # JCB: ensure that the fact value is not nil >> Facter::Util::Resolution.exec("grep #{db} /etc/fstab | awk {'print >> $1'}") or '' >> } >> end >> end >> end >> >> >> >> John >> >> -- 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+unsubscr...@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.