Skip to content
This repository has been archived by the owner on Aug 27, 2024. It is now read-only.

Uninstall not working #52

Open
adcorcoles opened this issue Mar 17, 2022 · 0 comments
Open

Uninstall not working #52

adcorcoles opened this issue Mar 17, 2022 · 0 comments

Comments

@adcorcoles
Copy link

In the uninstall class the find_file function is used to check if the path $created_dir exists and determine if the uninstall script should be run. This function is executed on the puppet server instead of the agent so the behavior is not as expected.

Since the uninstall is done through Exec resources, the onlyif attribute could be used to check the existence of the $created_dir path in the agent instead of using the find_file function and the $created_dir_exists variable.

The following commands could be used to perform the required check:

Linux/AIX: test -f '${created_dir}'
Windows PowerShell: Test-Path -Path '${created_dir}' -PathType Leaf

The class would be as follows:

class dynatraceoneagent::uninstall {

  $provider                            = $dynatraceoneagent::provider
  $install_dir                         = $dynatraceoneagent::install_dir
  $created_dir                         = $dynatraceoneagent::created_dir

  if ($::kernel == 'Linux' or $::osfamily == 'AIX') {
    exec { 'uninstall_oneagent':
      command   => "${install_dir}/agent/uninstall.sh",
      onlyif    => "test -f '${created_dir}'",
      timeout   => 6000,
      provider  => $provider,
      logoutput => on_failure,
    }
  } elsif $::osfamily == 'Windows' {
    $uninstall_command = @(EOT)
      $app = Get-WmiObject win32_product -filter "Name like 'Dynatrace OneAgent'"
      msiexec /x $app.IdentifyingNumber /quiet /l*vx uninstall.log
      | EOT

    exec { 'uninstall_oneagent':
      command   => $uninstall_command,
      onlyif    => "Test-Path -Path '${created_dir}' -PathType Leaf",
      timeout   => 6000,
      provider  => powershell,
      logoutput => on_failure,
    }
  }

}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant