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

Uninstall not working #52

@adcorcoles

Description

@adcorcoles

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,
    }
  }

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions