Puppet Class: prometheus::mysqld_exporter

Inherits:
prometheus
Defined in:
manifests/mysqld_exporter.pp

Summary

manages prometheus mysqld_exporter

Overview

Parameters:

  • cnf_config_path (Stdlib::Absolutepath) (defaults to: '/etc/mysqld_exporter-my.cnf')

    The path to put the my.cnf file

  • cnf_host (Stdlib::Host) (defaults to: localhost)

    The mysql host.

  • cnf_password (Variant[Sensitive[String],String]) (defaults to: 'password')

    The mysql user password.

  • cnf_port (Stdlib::Port) (defaults to: 3306)

    The port for which the mysql host is running.

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

    The socket which the mysql host is running. If defined, host and port are not used.

  • cnf_user (String[1]) (defaults to: login)

    The mysql user to use when connecting.

  • arch (String[1]) (defaults to: $prometheus::real_arch)

    Architecture (amd64 or i386)

  • bin_dir (Stdlib::Absolutepath) (defaults to: $prometheus::bin_dir)

    Directory where binaries are located

  • config_mode (String[1]) (defaults to: $prometheus::config_mode)

    The permissions of the configuration files

  • download_extension (String) (defaults to: 'tar.gz')

    Extension for the release binary archive

  • download_url (Optional[Prometheus::Uri]) (defaults to: undef)

    Complete URL corresponding to the where the release binary archive can be downloaded

  • download_url_base (Prometheus::Uri) (defaults to: 'https://github.com/prometheus/mysqld_exporter/releases')

    Base URL for the binary archive

  • extra_groups (Array) (defaults to: [])

    Extra groups to add the binary user to

  • extra_options (Optional[String[1]]) (defaults to: undef)

    Extra options added to the startup command

  • group (String[1]) (defaults to: 'mysqld-exporter')

    Group under which the binary is running

  • init_style (Prometheus::Initstyle) (defaults to: $prometheus::init_style)

    Service startup scripts style (e.g. rc, upstart or systemd)

  • install_method (Prometheus::Install) (defaults to: $prometheus::install_method)

    Installation method: url or package (only url is supported currently)

  • manage_group (Boolean) (defaults to: true)

    Whether to create a group for or rely on external code for that

  • manage_service (Boolean) (defaults to: true)

    Should puppet manage the service?

  • manage_user (Boolean) (defaults to: true)

    Whether to create user or rely on external code for that

  • os (String[1]) (defaults to: downcase($facts['kernel']))

    Operating system (linux is the only one supported)

  • package_ensure (String[1]) (defaults to: 'latest')

    If package, then use this for package ensure default ‘latest’

  • package_name (String[1]) (defaults to: 'mysqld_exporter')

    The binary package name - not available yet

  • purge_config_dir (Boolean) (defaults to: true)

    Purge config files no longer generated by Puppet

  • restart_on_change (Boolean) (defaults to: true)

    Should puppet restart the service on configuration change?

  • service_enable (Boolean) (defaults to: true)

    Whether to enable the service from puppet

  • service_ensure (Stdlib::Ensure::Service) (defaults to: 'running')

    State ensured for the service

  • service_name (String[1]) (defaults to: 'mysqld_exporter')

    Name of the mysqld exporter service

  • user (String[1]) (defaults to: 'mysqld-exporter')

    User which runs the service

  • version (String[1]) (defaults to: '0.17.2')

    The binary release version

  • proxy_server (Optional[String[1]]) (defaults to: undef)

    proxy server, with port number if needed. ie: example.com:8080

  • proxy_type (Optional[Enum['none', 'http', 'https', 'ftp']]) (defaults to: undef)

    proxy server type

  • web_config_file (Stdlib::Absolutepath) (defaults to: '/etc/mysqld_exporter_web-config.yml')

    Path of file where the web-config will be saved to

  • web_config_content (Prometheus::Web_config) (defaults to: {})

    Unless empty the content of the web-config yaml which will handed over as option to the exporter

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

    The path name of the Certificate Authority (CA) certificate file in PEM format.

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

    The path name of the client SSL public key certificate file in PEM format.

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

    The path name of the client SSL private key file in PEM format.

  • export_scrape_job (Boolean) (defaults to: false)
  • scrape_host (Optional[Stdlib::Host]) (defaults to: undef)
  • scrape_port (Stdlib::Port) (defaults to: 9104)
  • scrape_job_name (String[1]) (defaults to: 'mysql')
  • scrape_job_labels (Optional[Hash]) (defaults to: undef)

See Also:



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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'manifests/mysqld_exporter.pp', line 77

class prometheus::mysqld_exporter (
  String $download_extension = 'tar.gz',
  Prometheus::Uri $download_url_base = 'https://github.com/prometheus/mysqld_exporter/releases',
  Array $extra_groups = [],
  String[1] $group = 'mysqld-exporter',
  String[1] $package_ensure = 'latest',
  String[1] $package_name = 'mysqld_exporter',
  String[1] $user = 'mysqld-exporter',
  # renovate: depName=prometheus/mysqld_exporter
  String[1] $version                                         = '0.17.2',
  String[1] $service_name = 'mysqld_exporter',
  Stdlib::Absolutepath $cnf_config_path                      = '/etc/mysqld_exporter-my.cnf',
  Stdlib::Host $cnf_host                                     = localhost,
  Stdlib::Port $cnf_port                                     = 3306,
  String[1] $cnf_user                                        = login,
  Variant[Sensitive[String],String] $cnf_password            = 'password',
  Optional[Stdlib::Absolutepath] $cnf_socket                 = undef,
  Boolean $purge_config_dir                                  = true,
  Boolean $restart_on_change                                 = true,
  Boolean $service_enable                                    = true,
  Stdlib::Ensure::Service $service_ensure                    = 'running',
  Prometheus::Initstyle $init_style                          = $prometheus::init_style,
  Prometheus::Install $install_method                        = $prometheus::install_method,
  Boolean $manage_group                                      = true,
  Boolean $manage_service                                    = true,
  Boolean $manage_user                                       = true,
  String[1] $os                                              = downcase($facts['kernel']),
  Optional[String[1]] $extra_options                         = undef,
  Optional[Prometheus::Uri] $download_url                    = undef,
  String[1] $config_mode                                     = $prometheus::config_mode,
  String[1] $arch                                            = $prometheus::real_arch,
  Stdlib::Absolutepath $bin_dir                              = $prometheus::bin_dir,
  Boolean $export_scrape_job                                 = false,
  Optional[Stdlib::Host] $scrape_host                        = undef,
  Stdlib::Port $scrape_port                                  = 9104,
  String[1] $scrape_job_name                                 = 'mysql',
  Optional[Hash] $scrape_job_labels                          = undef,
  Optional[String[1]] $proxy_server                          = undef,
  Optional[Enum['none', 'http', 'https', 'ftp']] $proxy_type = undef,
  Stdlib::Absolutepath $web_config_file                      = '/etc/mysqld_exporter_web-config.yml',
  Prometheus::Web_config $web_config_content                 = {},
  Optional[Stdlib::Absolutepath] $cnf_ssl_ca                 = undef,
  Optional[Stdlib::Absolutepath] $cnf_ssl_cert               = undef,
  Optional[Stdlib::Absolutepath] $cnf_ssl_key                = undef,
) inherits prometheus {
  #Please provide the download_url for versions < 0.9.0
  $real_download_url = pick($download_url,"${download_url_base}/download/v${version}/${package_name}-${version}.${os}-${arch}.${download_extension}")
  $notify_service = $restart_on_change ? {
    true    => Service[$service_name],
    default => undef,
  }

  $_cnf_settings = {
    'user'     => $cnf_user,
    'password' => $cnf_password,
    'port'     => $cnf_port,
    'host'     => $cnf_host,
    'socket'   => $cnf_socket,
    'ssl-ca'   => $cnf_ssl_ca,
    'ssl-cert' => $cnf_ssl_cert,
    'ssl-key'  => $cnf_ssl_key,
  }.filter |$k, $v| { $v != undef }

  file { $cnf_config_path:
    ensure  => file,
    mode    => $config_mode,
    owner   => $user,
    group   => $group,
    content => Sensitive(
      epp(
        'prometheus/my.cnf.epp',
        { 'settings' => $_cnf_settings }
      )
    ),
    notify  => $notify_service,
  }

  $_web_config_ensure = $web_config_content.empty ? {
    true    => absent,
    default => file,
  }

  file { $web_config_file:
    ensure  => $_web_config_ensure,
    owner   => $user,
    group   => $group,
    mode    => '0640',
    content => $web_config_content.stdlib::to_yaml,
    notify  => $notify_service,
  }

  $_web_config = if $web_config_content.empty {
    ''
  } else {
    "--web.config.file=${$web_config_file}"
  }
  $_config_myconf = if versioncmp($version, '0.11.0') < 0 {
    "-config.my-cnf=${cnf_config_path}"
  } else {
    "--config.my-cnf=${cnf_config_path}"
  }

  $options = [
    $_config_myconf,
    $extra_options,
    $_web_config,
  ].filter |$x| { !$x.empty }.join(' ')

  prometheus::daemon { $service_name:
    install_method     => $install_method,
    version            => $version,
    download_extension => $download_extension,
    os                 => $os,
    arch               => $arch,
    real_download_url  => $real_download_url,
    bin_dir            => $bin_dir,
    notify_service     => $notify_service,
    package_name       => $package_name,
    package_ensure     => $package_ensure,
    manage_user        => $manage_user,
    user               => $user,
    extra_groups       => $extra_groups,
    group              => $group,
    manage_group       => $manage_group,
    purge              => $purge_config_dir,
    options            => $options,
    init_style         => $init_style,
    service_ensure     => $service_ensure,
    service_enable     => $service_enable,
    manage_service     => $manage_service,
    export_scrape_job  => $export_scrape_job,
    scrape_host        => $scrape_host,
    scrape_port        => $scrape_port,
    scrape_job_name    => $scrape_job_name,
    scrape_job_labels  => $scrape_job_labels,
    proxy_server       => $proxy_server,
    proxy_type         => $proxy_type,
  }
}