aboutsummaryrefslogtreecommitdiff
path: root/plugins/facter/virtual.rb
diff options
context:
space:
mode:
authorMicah Anderson <micah@riseup.net>2007-10-12 16:14:11 +0000
committerMicah Anderson <micah@riseup.net>2007-10-12 16:14:11 +0000
commit284b50a1d07310c8c10f1c1f953d1e979762c476 (patch)
tree3974da499c584648e3aefbb8be13270f3d90ff93 /plugins/facter/virtual.rb
downloadpuppet-virtual-284b50a1d07310c8c10f1c1f953d1e979762c476.tar.gz
puppet-virtual-284b50a1d07310c8c10f1c1f953d1e979762c476.tar.bz2
add the virtual module
Diffstat (limited to 'plugins/facter/virtual.rb')
-rw-r--r--plugins/facter/virtual.rb39
1 files changed, 39 insertions, 0 deletions
diff --git a/plugins/facter/virtual.rb b/plugins/facter/virtual.rb
new file mode 100644
index 0000000..e649345
--- /dev/null
+++ b/plugins/facter/virtual.rb
@@ -0,0 +1,39 @@
+# Copied from http://reductivelabs.com/trac/puppet/wiki/VirtualRecipe?version=6
+# Authored by abnormaliti with contributions by daniel@nsp.co.nz and mwr
+
+# This defines the fact "virtual" with the possible values of "physical",
+# "vmware", "vmware_server", "xenu", or "xen0"
+
+Facter.add("virtual") do
+ confine :kernel => :linux
+
+ ENV["PATH"]="/bin:/sbin:/usr/bin:/usr/sbin"
+
+ result = "physical"
+
+ setcode do
+
+ lspciexists = system "which lspci >&/dev/null"
+ if $?.exitstatus == 0
+ output = %x{lspci}
+ output.each {|p|
+ # --- look for the vmware video card to determine if it is virtual => vmware.
+ # --- 00:0f.0 VGA compatible controller: VMware Inc [VMware SVGA II] PCI Display Adapter
+ result = "vmware" if p =~ /VMware/
+ }
+ end
+
+ # VMware server 1.0.3 rpm places vmware-vmx in this place, other versions or platforms may not.
+ if FileTest.exists?("/usr/lib/vmware/bin/vmware-vmx")
+ result = "vmware_server"
+ end
+
+ if FileTest.exists?("/proc/xen/capabilities") and File.read("/proc/xen/capabilities") =~ /control_d/i
+ result = "xen0"
+ elsif FileTest.exists?("/proc/sys/xen/independent_wallclock")
+ result = "xenu"
+ end
+ result
+ end
+end
+