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
|
# File 'manifests/openldap_exporter.pp', line 53
class prometheus::openldap_exporter (
String $download_extension = 'tar.gz',
Array[String] $extra_groups = [],
String[1] $group = 'openldap-exporter',
String[1] $package_ensure = 'latest',
String[1] $user = 'openldap-exporter',
# renovate: depName=hm-edu/openldap-exporter
String[1] $version = 'v2.7.0',
Prometheus::Uri $download_url_base = 'https://github.com/hm-edu/openldap-exporter/releases',
String[1] $package_name = 'openldap-exporter',
String[1] $service_name = 'openldap_exporter',
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']),
String $options = '', # lint:ignore:params_empty_string_assignment
Optional[Prometheus::Uri] $download_url = undef,
Stdlib::Absolutepath $bin_dir = $prometheus::bin_dir,
Boolean $export_scrape_job = false,
Optional[Stdlib::Host] $scrape_host = undef,
Stdlib::Port $scrape_port = 9330,
String[1] $scrape_job_name = 'openldap',
Optional[Hash] $scrape_job_labels = undef,
Optional[String[1]] $ldap_binddn = undef,
Optional[String[1]] $ldap_password = undef,
Optional[String[1]] $proxy_server = undef,
Optional[Enum['none', 'http', 'https', 'ftp']] $proxy_type = undef,
) inherits prometheus {
# package does not follow the $prometheus::real_arch naming for x86_64
# but also does not follw the $prometheus::arch naming for aarch64 and armv6l
# there are no other arch released
$real_arch = $prometheus::arch ? {
'aarch64' => $prometheus::real_arch,
'armv6l' => $prometheus::real_arch,
'amd64' => 'x86_64',
default => $prometheus::arch,
}
$real_download_url = pick($download_url,"${download_url_base}/download/${version}/${package_name}_${os}_${real_arch}.${download_extension}")
# For compatibility with previous versions, we keep the previous name for the service
# but since the binary has changed name, we need to specify it manually.
$extract_path = "/opt/${service_name}-${version}.${os}-${real_arch}"
$archive_bin_path = "${extract_path}/${package_name}"
file { $extract_path:
ensure => 'directory',
owner => 'root',
group => 0, # 0 instead of root because OS X uses "wheel".
mode => '0755',
before => Prometheus::Daemon[$service_name],
}
$notify_service = $restart_on_change ? {
true => Service[$service_name],
default => undef,
}
if $ldap_binddn != undef and $ldap_password != undef {
$env_vars = {
'LDAP_USER' => $ldap_binddn,
'LDAP_PASS' => $ldap_password,
}
} else {
$env_vars = {}
}
prometheus::daemon { $service_name:
install_method => $install_method,
version => $version,
download_extension => $download_extension,
os => $os,
real_download_url => $real_download_url,
extract_path => $extract_path,
archive_bin_path => $archive_bin_path,
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,
options => $options,
init_style => $init_style,
service_ensure => $service_ensure,
service_enable => $service_enable,
manage_service => $manage_service,
env_vars => $env_vars,
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,
}
}
|