Defined Type: tp::uninstall

Defined in:
manifests/uninstall.pp

Overview

This define uninstalls the application (app) defined in title. It may also remove the relevant repository and configuration files.

Examples:

removal (of any any supported app and OS):

tp::uninstall { $app: }

remove also configuration file(s) and dirs (DANGER ZONE!)

tp::uninstall { 'postfix':
  conf_hash => $postfix_files,
  dir_hash  => $postfix_dirs,
}

Parameters:

  • conf_hash (Hash) (defaults to: {})

    An hash of tp::conf resources to remove.

  • dir_hash (Hash) (defaults to: {})

    An hash of tp::dir resources to remove.

  • settings_hash (Hash) (defaults to: {})

    An hash that can override the application settings returned by tp according to the underlying OS defaults.

  • auto_repo (Boolean) (defaults to: true)

    Boolean to enable automatic package repo management for the specified application. If true, also the relevant app repo is removed.

  • data_module (String[1]) (defaults to: 'tinydata')

    Name of the module where tp data is looked for Default is tinydata: github.com/example42/tinydata



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'manifests/uninstall.pp', line 29

define tp::uninstall (
  Hash      $conf_hash                 = {},
  Hash      $dir_hash                  = {},
  Hash      $settings_hash             = {},
  Boolean   $auto_repo                 = true,
  String[1] $data_module               = 'tinydata',
) {
  # Settings evaluation
  $tp_settings=tp_lookup($title,'settings',$data_module,'deep_merge')
  $settings = $tp_settings + $settings_hash

  # Automatic repo management
  if $auto_repo == true
  and ( $settings['repo_url'] or $settings['yum_mirrorlist']) {
    tp::repo { $title:
      enabled => false,
      before  => Package[$settings[package_name]],
    }
  }

  # Resources removed
  if $settings[package_name] {
    ensure_resource( 'package', $settings[package_name], {
        'ensure' => 'absent',
    })
  }

  if $settings[service_name] {
    ensure_resource( 'service', $settings[service_name], {
        'ensure'  => 'stopped',
        'enable'  => false,
    })
  }

  if $conf_hash != {} {
    $conf_hash.each |$k,$v| {
      tp::conf { $k:
        ensure => absent,
      }
    }
  }
  if $dir_hash != {} {
    $dir_hash.each |$k,$v| {
      tp::dir { $k:
        ensure => absent,
      }
    }
  }
}