I think your facter version is rather old. On facter 1.5.4 (and probably
before), as long as I have dmidecode installed, facter presents several
variables that can be used to identify VM's without any coding.

manufacturer => VMware, Inc.
virtual => vmware

manufacturer => Xen
virtual => physical

It appears that $virtual doesn't work on Xen :(

Steve Wray wrote:
> FYI I've butchered this into place now by dropping my custom facts into 
> /usr/lib/ruby/1.8/facter/
>
> Obviously this isn't ideal but its all I've found that works.
> :(
>
> Joshua Anderson wrote:
>   
>> You have to run facter with the "-p" argument if you want to see facts  
>> distributed by Puppet.
>>
>> -Josh
>>
>> On Mar 9, 2009, at 1:50 PM, Steve Wray wrote:
>>
>>     
>>> 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.
>>>
>>>
>>>
>>> -- 
>>> Please remember that an email is just like a postcard; it is not
>>> confidential nor private nor secure and can be read by many other  
>>> people
>>> than the intended recipient. A postcard can be read by anyone at the  
>>> mail
>>> sorting office and expecting what is written on it to be private and  
>>> secret
>>> is not realistic. Please hold no higher expectation of email.
>>>
>>> If you need to send confidential information in an email you need to  
>>> use
>>> encryption. PGP is Pretty good for this.
>>>
>>>       
>>     
>
>
>   

-- 

Trevor Hemsley
Infrastructure Engineer
.................................................
* C A L Y P S O
* 4th Floor, Tower Point,
44 North Road,
Brighton, BN1 1YR, UK   

OFFICE  +44 (0) 1273 666 350
FAX     +44 (0) 1273 666 351

.................................................
www.calypso.com

This electronic-mail might contain confidential information intended
only for the use by the entity named. If the reader of this message is
not the intended recipient, the reader is hereby notified that any
dissemination, distribution or copying is strictly prohibited.

* P * /*/ Please consider the environment before printing this e-mail /*/


--~--~---------~--~----~------------~-------~--~----~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to