VMware
Timekeeping on VMware is more difficult that on a standard machine because some of the devices that VMware emulates can not provide the same reliability that they can when they are not virtual. There are work around however, so it's important to be able to detect that a host is a VMware guest or not to decide which route to have puppet take for timekeeping.
Are we a VMware guest?
This solution require the manufacturer.rb facter plugin available since facter-1.3.8.
# VMware guest detection
case $productname {
'VMware Virtual Platform': {
notice "I'm a vmware guest"
}
default: {
notice "I'm NOT a vmware guest
}
}
VMWare Tools
The above can be used to automatically install vmware-tools. VMware has open sourced the tools. Future versions of debian will have the open-vm-tools package and some people have created backports for etch. There are packages for other distributions such as centos as well, check with your personal choice of distro.
class vmware {
# Detect that we're a vmware guest
case $productname {
'VMware Virtual Platform': {
# install vmware tools
package { "open-vm-tools":
name => "open-vm-tools",
ensure => present,
}
}
}
}
An older solution example
we need to determine if a certain host is running within vmware, if this is the case we must not install a timekeeping daemon, since they always get confused. we may also consider installing vmware tools automatically via puppet in the future.
The vmware fact below doesn't work an a host computer running vmware workstation because vmnetX interface also have mac addresses registered by Vmware Corp.
MAC OUIs are also somewhat variable, this is a good example but the above example is more reliable at this point.
require 'facter'
Facter.add("Vmware") do
#confine :kernel => %w{Solaris Linux}
confine :operatingsystem => %w{Solaris Linux Fedora RedHat CentOS SuSE Debian Gentoo}
setcode do
ether = []
output = %x{/sbin/ifconfig -a}
output.each {|s|
ether.push($1) if s =~ /(?:ether|HWaddr) (\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2})/
}
result = "physical"
ether.each{|mac|
if mac =~ /(00:0C:29|00:05:69|00:50:56):\w{1,2}:\w{1,2}:\w{1,2}/i
result = "virtual"
break
end
}
result
end
end
We decided that all our machines are going to have network interface cards (at least if we manage them via puppet), so checking the mac address seemed a natural choice. We're installing via HTTP, simply because I like that as a way of not keeping the install file around, however you could split it into more discrete steps if need be (and it would probably be wise to do so!)
Note the PAGER=/bin/cat - that's required for the installer to work, otherwise it will enter an infinite loop!
http://coffer.com/mac_find/ finds the following for "vmware":
- 00:0C:29
- 00:05:69
- 00:50:56
Our first attempt using wildcard matches within puppet recipes turned out not to work, so creating a facter recipe was choosen.
case $macaddress {
"00:0C:29:*":{
file{ "/etc/running_inside_vmware": ensure => present }
}
}