Defined Type: pcp::pmda

Defined in:
manifests/pmda.pp

Summary

Install, enable and optionally configure a PMDA

Overview

Examples:

pcp::pmda { 'nfsclient':
  ensure => 'present',
}

Parameters:

  • ensure (Enum['present', 'absent']) (defaults to: 'present')

    Ensure property for the PMDA. Valid values are 'present' and 'absent'. Default is 'present'.

  • has_package (Boolean) (defaults to: true)

    Boolean that determines of a package is associated with the PMDA. Default is true.

  • package_name (Optional[String]) (defaults to: undef)

    Package name of PMDA. Default is pcp-pmda-$name.

  • remove_package (Boolean) (defaults to: false)

    Boolean that determines if the package should be removed when ensure is absent. Default is false.

  • config_path (Optional[Stdlib::Absolutepath]) (defaults to: undef)

    Configuration file path for this PMDA. Default is /var/lib/pcp/config/${name}/${name}.conf.

  • config_content (Optional[String]) (defaults to: undef)

    Configuration file content for the PMDA. Default is undef.

  • config_source (Optional[String]) (defaults to: undef)

    Configuration file source for the PMDA. Default is undef.

  • args (Optional[String]) (defaults to: undef)

    Arguments that will be added to pmcd.conf for this PMDA



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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'manifests/pmda.pp', line 34

define pcp::pmda (
  Enum['present', 'absent'] $ensure           = 'present',
  Boolean $has_package                        = true,
  Optional[String] $package_name              = undef,
  Boolean $remove_package                     = false,
  Optional[Stdlib::Absolutepath] $config_path = undef,
  Optional[String] $config_content            = undef,
  Optional[String] $config_source             = undef,
  Optional[String] $args                      = undef,
) {
  include pcp

  $_package_name = pick($package_name, "pcp-pmda-${name}")
  $_config_path  = pick($config_path, "/var/lib/pcp/config/${name}/${name}.conf")
  $_config_dir   = dirname($_config_path)
  $_pmda_dir     = "/var/lib/pcp/pmdas/${name}"

  case $ensure {
    'present': {
      if $has_package {
        package { "pcp-pmda-${name}":
          ensure  => $pcp::_package_ensure,
          name    => $_package_name,
          require => Class['pcp::install'],
          before  => File_line["${name}-args"],
          notify  => Exec["install-${name}"],
        }
      }

      if $config_content or $config_source {
        file { "pmda-config-dir-${name}":
          ensure  => 'directory',
          path    => $_config_dir,
          owner   => 'root',
          group   => 'root',
          mode    => '0755',
          require => Class['pcp::install'],
        }
        -> file { "pmda-config-${name}":
          ensure  => 'file',
          path    => $_config_path,
          owner   => 'root',
          group   => 'root',
          mode    => '0644',
          content => $config_content,
          source  => $config_source,
          before  => Exec["install-${name}"],
          notify  => Service['pmcd'],
        }
      }

      if $args {
        $file_line = {
          'ensure' => 'present',
          'line'   => "args=\"${args}\"",
          'match'  => '^args',
          'after'  => '^iam',
        }
      } else {
        $file_line = {
          'ensure'            => 'absent',
          'match'             => '^args',
          'match_for_absence' => true,
        }
      }

      file_line { "${name}-args":
        path   => "${_pmda_dir}/Install",
        notify => Exec["refresh-install-${name}"],
        *      => $file_line,
      }

      exec { "install-${name}":
        path    => '/usr/bin:/bin:/usr/sbin:/sbin',
        command => "touch ${_pmda_dir}/.NeedInstall",
        creates => "${_pmda_dir}/.NeedInstall",
        unless  => "egrep -q '^${name}\\s+' /etc/pcp/pmcd/pmcd.conf",
        notify  => Service['pmcd'],
      }
      exec { "refresh-install-${name}":
        path        => '/usr/bin:/bin:/usr/sbin:/sbin',
        command     => "touch ${_pmda_dir}/.NeedInstall",
        refreshonly => true,
        notify      => Service['pmcd'],
      }
    }
    'absent': {
      if $remove_package and $has_package {
        package { "pcp-pmda-${name}":
          ensure            => 'absent',
          name              => $_package_name,
          require           => Exec["remove-${name}"],
          provider          => 'rpm',
          uninstall_options => ['--nodeps'],
        }
      }

      if $config_content or $config_source {
        file { "pmda-config-${name}":
          ensure => 'absent',
          path   => $_config_path,
        }
        -> file { "pmda-config-dir-${name}":
          ensure => 'absent',
          path   => $_config_dir,
          force  => true,
        }
      }

      exec { "remove-${name}":
        path    => '/usr/bin:/bin:/usr/sbin:/sbin',
        command => "touch ${_pmda_dir}/.NeedRemove",
        creates => "${_pmda_dir}/.NeedRemove",
        onlyif  => "egrep -q '^${name}\\s+' /etc/pcp/pmcd/pmcd.conf",
        notify  => Service['pmcd'],
      }
    }
    default: {
      fail("pcp::pmda: ensure must be present or absent, ${ensure} given.")
    }
  }
}