
# Install VMware optimizations if running as guest.
#
class vmware::guest {

    case $virtual {
	vmware: {
	    case $operatingsystem {
		centos: { include vmware::guest::centos }
		fedora: { include vmware::guest::fedora }
	    }
	}
    }

}


# Handler for CentOS.
#
class vmware::guest::centos {

    package { "VMwareTools":
	ensure => installed,
    }
    exec { "vmware-config-tools.pl":
	command     => "unset DISPLAY REMOTEHOST SSH_CONNECTION ; perl /usr/bin/vmware-config-tools.pl -d",
	path        => "/bin:/usr/bin:/sbin:/usr/sbin",
	environment => [ "PAGER=/bin/cat", ],
	unless      => "test -f /lib/modules/$kernelrelease/misc/vmci.ko",
	require     => Package["VMwareTools"],
    }
    service { "vmware-tools":
	enable    => true,
	ensure    => running,
	subscribe => Exec["vmware-config-tools.pl"],
	require   => Exec["vmware-config-tools.pl"],
    }

}


# Handler for Fedora.
#
# VMware tools do not keep up with Fedora kernels so use
# open-vm-tools instead.
#
class vmware::guest::fedora {

    package { "VMwareTools":
	ensure => absent,
    }
    package { "open-vm-tools":
	ensure  => installed,
	require => Package["VMwareTools"],
    }

}
