Puppet Class: prometheus::postfix_exporter

Defined in:
manifests/postfix_exporter.pp

Summary

manages prometheus postfix_exporter

Overview

Examples:

Basic usage

include prometheus::postfix_exporter

Parameters:

  • install_method (Prometheus::Install) (defaults to: 'url')

    Installation method: ‘url` or `package`. (Note `package` is not available on most OSes.)

  • download_url (Optional[Stdlib::HTTPUrl]) (defaults to: undef)

    Complete URL corresponding to the where the release can be downloaded. (This option is only relevant when ‘install_method` is `url`.)

  • download_url_base (Stdlib::HTTPUrl) (defaults to: 'https://github.com/kumina/postfix_exporter/releases')

    Base URL for the binary archive. (This option is only relevant when ‘install_method` is `url`.)

  • download_extension (String) (defaults to: '')

    Extension for the release binary archive. (This option is only relevant when ‘install_method` is `url`.)

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

    The binary release version. (This option is only relevant when ‘install_method` is `url`.)

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

    Used when ‘install_method` is `package`.

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

    Used when ‘install_method` is `package`.

  • manage_user (Boolean) (defaults to: true)

    Whether to create and manage the exporter’s user. This can eg. be set to ‘false` if your package already creates a user for you.

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

    User which runs the service.

  • manage_group (Boolean) (defaults to: true)

    Whether to create and manage the exporter’s group. This can eg. be set to ‘false` if your package already creates a group for you.

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

    Group to run the service as.

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

    Extra groups to add the exporter user to.

  • manage_service (Boolean) (defaults to: true)

    Should puppet manage the service?

  • init_style (Optional[Prometheus::Initstyle]) (defaults to: undef)

    Service startup scripts style. When not set, the correct default for your OS will be used. Can also be set to ‘none` when you don’t want the class to create a startup script/unit_file for you. Typically this can be used when a package is already providing the file.

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

    The name of the service.

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

    Desired state for the service.

  • service_enable (Boolean) (defaults to: true)

    Whether to enable the service from puppet.

  • extra_options (String) (defaults to: '--systemd.enable --systemd.unit=\'postfix.service\' --postfix.logfile_path=\'\'')

    Extra options added to the startup command. Override these if you want to monitor a logfile instead of systemd.

  • restart_on_change (Boolean) (defaults to: true)

    Should puppet restart the service on configuration change?

  • export_scrape_job (Boolean) (defaults to: false)

    Whether to export a ‘prometheus::scrape_job` to puppetDB for collecting on your prometheus server.

  • scrape_port (Stdlib::Port) (defaults to: 9154)

    The port to use in the scrape job. This won’t normally need to be changed unless you run the exporter with a non-default port by overriding ‘extra_options`.

  • scrape_job_name (String[1]) (defaults to: 'postfix')

    The name of the scrape job. When configuring prometheus with this puppet module, the jobs to be collected are configured with ‘prometheus::collect_scrape_jobs`.

  • scrape_job_labels (Optional[Hash]) (defaults to: undef)

    Labels to configure on the scrape job. If not set, the ‘prometheus::daemon` default (`{ ’alias’ => $scrape_host }‘) will be used.

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

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

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

    Optional proxy server type (none|http|https|ftp)

  • scrape_host (Optional[Stdlib::Host]) (defaults to: undef)

See Also:



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
# File 'manifests/postfix_exporter.pp', line 57

class prometheus::postfix_exporter (
  # Installation options
  Prometheus::Install $install_method                        = 'url',
  Optional[Stdlib::HTTPUrl] $download_url                    = undef,
  Stdlib::HTTPUrl $download_url_base                         = 'https://github.com/kumina/postfix_exporter/releases',
  String $download_extension                                 = '', # lint:ignore:params_empty_string_assignment
  String[1] $version                                         = '0.2.0',
  Optional[String[1]] $proxy_server                          = undef,
  Optional[Enum['none', 'http', 'https', 'ftp']] $proxy_type = undef,

  # Package options (relevant when `install_method == 'package'`)
  String[1] $package_ensure               = 'installed',
  String[1] $package_name                 = 'postfix_exporter',

  # user/group configuration
  Boolean          $manage_user  = true,
  String[1]        $user         = 'postfix-exporter',
  Boolean          $manage_group = true,
  String[1]        $group        = 'postfix-exporter',
  Array[String[1]] $extra_groups = [],

  # service related options
  Boolean                         $manage_service = true,
  Optional[Prometheus::Initstyle] $init_style     = undef,
  String[1]                       $service_name   = 'postfix_exporter',
  Stdlib::Ensure::Service         $service_ensure = 'running',
  Boolean                         $service_enable = true,

  # exporter configuration
  String  $extra_options     = '--systemd.enable --systemd.unit=\'postfix.service\' --postfix.logfile_path=\'\'',
  Boolean $restart_on_change = true,

  # scrape job configuration
  Boolean        $export_scrape_job = false,
  Optional[Stdlib::Host] $scrape_host  = undef,
  Stdlib::Port   $scrape_port       = 9154,
  String[1]      $scrape_job_name   = 'postfix',
  Optional[Hash] $scrape_job_labels = undef,
) {
  include prometheus

  $real_download_url = pick($download_url,"${download_url_base}/download/${version}/${package_name}")
  $notify_service = $restart_on_change ? {
    true    => Service[$service_name],
    default => undef,
  }

  prometheus::daemon { $service_name:
    install_method     => $install_method,
    version            => $version,
    download_extension => $download_extension,
    os                 => $prometheus::os,
    arch               => $prometheus::real_arch,
    real_download_url  => $real_download_url,
    bin_dir            => $prometheus::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,
    options            => $extra_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,
  }
}