Le mardi 10 mars 2009 à 09:50 +1300, Steve Wray a écrit :
> Hi there,
> 
> I'm trying to use a fact to tell whether the machine is virtualised.
> 
> I found this and, in testing, its been ok:
> http://reductivelabs.com/trac/puppet/wiki/Recipes/VirtualMachine
> 
> However, trying to roll this new fact out has been difficult.
> 
> 1. Debian has got facter looking in /var/puppet/facts while the package 
> maintainer has other puppet var stuff in /var/lib/puppet/ I used puppet to 
> create a symlink to work around this.
> 
> 2. Following the instructions in 
> http://reductivelabs.com/trac/puppet/wiki/AddingFacts
> I can test this properly from the commandline by setting environment 
> variables etc so I know that the ruby code is working.
> 
> Ie:
> mkdir -p ~/lib/ruby/facter
> export RUBYLIB=~/lib/ruby
> cp /var/lib/puppet/facts/virtual.rb $RUBYLIB/facter
> facter virtual
> 
> does return the expected output.
> 
> 
> 3. When I run facter from the commandline, without directing $RUBYLIB to my 
> home directory, I don't get the expected output.
> 
> When I run facter from strace I can see:
> 
> open("/var/puppet/facts/virtual.rb", O_RDONLY|O_LARGEFILE) = 4
> close(4)                                = 0
> sigprocmask(SIG_BLOCK, NULL, [])        = 0
> open("/var/puppet/facts/virtual.rb", O_RDONLY|O_LARGEFILE) = 4
> close(4)                                = 0
> open("/var/puppet/facts/virtual.rb", O_RDONLY|O_LARGEFILE) = 4
> fstat64(4, {st_mode=S_IFREG|0755, st_size=1435, ...}) = 0
> mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
> 0xb7f67000
> read(4, "Facter.add(\"virtual\") do\n  confi"..., 4096) = 1435
> 
> so I can tell that facter is reading this new fact file.
> 
> But when, from the commandline, I run "facter" or "facter virtual" I don't 
> get the expected output.

I've ran into the same problem, which is quite simple : facter 1.5.x
already provides a fact named "virtual", rename your fact to
"custom_virtual" (or whatever) and you'll be OK.

Nicolas.

-- 
Nicolas Szalay

Administrateur systèmes & réseaux

--                     _
ASCII ribbon campaign ( )
 - against HTML email  X
             & vCards / \

Attachment: signature.asc
Description: Ceci est une partie de message numériquement signée

Reply via email to