Skip to content

Commit

Permalink
Uninstall VMwareTools if installed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Vincent committed Jun 25, 2019
1 parent 6219b82 commit a57a111
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
10 changes: 10 additions & 0 deletions lib/facter/vmware_tools_uninstaller_path.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Fact to discover the VMwareTools uninstaller path, if any.

Facter.add(:vmware_tools_uninstaller_path) do
confine :kernel do |os|
os != "windows"
end
setcode do
Facter::Core::Execution.which('vmware-uninstall-tools.pl')
end
end
19 changes: 17 additions & 2 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
# Default: auto-set, platform specific
#
# [*service_name*]
# Name of openvmtools service.
# Name(s) of openvmtools service(s).
# Only set this if your platform is not supported or you know what you are
# doing.
# Default: auto-set, platform specific
Expand Down Expand Up @@ -79,7 +79,7 @@
Boolean $manage_epel = false,
String[1] $package_name = 'open-vm-tools',
Stdlib::Ensure::Service $service_ensure = 'running',
Variant[String[1],Array[String[1]]] $service_name = 'vmtoolsd',
Variant[String[1],Array[String[1]]] $service_name = ['vgauthd','vmtoolsd'],
Boolean $service_enable = true,
Boolean $service_hasstatus = true,
String[1] $service_pattern = 'vmtoolsd',
Expand Down Expand Up @@ -114,6 +114,21 @@
include epel
Yumrepo['epel'] -> Package[$packages]
}
$vmware_uninstaller = defined('$facts["vmware_tools_uninstaller_path"]') ? {
true => $facts['vmware_tools_uninstaller_path'],
default => null,
}
if $vmware_uninstaller =~ String {
$vmware_lib = $vmware_uninstaller.regex_replace('bin/vmware-uninstall-tools.pl','lib/vmware-tools')
exec { 'vmware-uninstall-tools':
command => "${vmware_uninstaller} && rm -rf ${vmware_lib}",
before => Package['VMwareTools'],
}
}
package { 'VMwareTools':
ensure => 'absent',
before => Package[$packages],
}
ensure_packages($packages, { 'ensure' => $package_ensure })
ensure_resource('service', $service_name, {
ensure => $service_ensure_real,
Expand Down

0 comments on commit a57a111

Please sign in to comment.