# Class: prometheus::snmp_exporter # # This module manages prometheus snmp_exporter # # Parameters: # [*arch*] # Architecture (amd64 or i386) # # [*bin_dir*] # Directory where binaries are located # # [*config_file*] # Absolute path to configuration file # # [*config_mode*] # Configuration file mode (default 0660) # # [*config_template*] # Configuration template to use. If empty, uses upstream config (default "") # # [*download_extension*] # Extension for the release binary archive # # [*download_url*] # Complete URL corresponding to the where the release binary archive can be downloaded # # [*download_url_base*] # Base URL for the binary archive # # [*extra_groups*] # Extra groups to add the binary user to # # [*extra_options*] # Extra options added to the startup command # # [*group*] # Group under which the binary is running # # [*init_style*] # Service startup scripts style (e.g. rc, upstart or systemd) # # [*install_method*] # Installation method: url or package (only url is supported currently) # # [*manage_group*] # Whether to create a group for or rely on external code for that # # [*manage_service*] # Should puppet manage the service? (default true) # # [*manage_user*] # Whether to create user or rely on external code for that # # [*os*] # Operating system (linux is the only one supported) # # [*package_ensure*] # If package, then use this for package ensure default 'latest' # # [*package_name*] # The binary package name - not available yet # # [*purge_config_dir*] # Purge config files no longer generated by Puppet # # [*restart_on_change*] # Should puppet restart the service on configuration change? (default true) # # [*service_enable*] # Whether to enable the service from puppet (default true) # # [*service_ensure*] # State ensured for the service (default 'running') # # [*user*] # User which runs the service # # [*version*] # The binary release version class prometheus::snmp_exporter ( String $arch = $::prometheus::params::arch, String $bin_dir = $::prometheus::params::bin_dir, String $config_file = $::prometheus::params::snmp_exporter_config_file, String $config_mode = $::prometheus::params::config_mode, String $config_template = $::prometheus::params::snmp_exporter_config_template, String $download_extension = $::prometheus::params::snmp_exporter_download_extension, Optional[String] $download_url = undef, String $download_url_base = $::prometheus::params::snmp_exporter_download_url_base, Array $extra_groups = $::prometheus::params::snmp_exporter_extra_groups, String $extra_options = '', String $group = $::prometheus::params::snmp_exporter_group, String $init_style = $::prometheus::params::init_style, String $install_method = $::prometheus::params::install_method, Boolean $manage_group = true, Boolean $manage_service = true, Boolean $manage_user = true, String $os = $::prometheus::params::os, String $package_ensure = $::prometheus::params::snmp_exporter_package_ensure, String $package_name = $::prometheus::params::snmp_exporter_package_name, Boolean $purge_config_dir = true, Boolean $restart_on_change = true, Boolean $service_enable = true, String $service_ensure = 'running', String $user = $::prometheus::params::snmp_exporter_user, String $version = $::prometheus::params::snmp_exporter_version, ) inherits prometheus::params { $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['snmp_exporter'], default => undef, } $options = "--config.file=${config_file} ${extra_options}" $_content = $config_template ? { '' => undef, default => template($config_template), } $_source = $config_template ? { '' => "file:/opt/snmp_exporter-${version}.${os}-${arch}/snmp.yml", default => undef, } $_require = $config_template ? { '' => File["/opt/snmp_exporter-${version}.${os}-${arch}/snmp_exporter"], default => undef, } file { $config_file: ensure => present, owner => $user, group => $group, mode => $config_mode, content => $_content, source => $_source, require => $_require, notify => $notify_service, } prometheus::daemon { 'snmp_exporter': 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, } }