Skip to content

Commit 7e52f28

Browse files
committed
Added ability to delete old releases
Move the URL releases to their own directory under /opt to create the possibility for Puppet to remove old releases that are no longer used.
1 parent 001ec20 commit 7e52f28

17 files changed

+47
-29
lines changed

manifests/alertmanager.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@
187187
# If version >= 0.10.0 then install amtool - Alertmanager validation tool
188188
file { "${bin_dir}/amtool":
189189
ensure => link,
190-
target => "/opt/${package_name}-${version}.${os}-${arch}/amtool",
190+
target => "${prometheus::basepath}/${package_name}-${version}.${os}-${arch}/amtool",
191191
}
192192

193193
if $manage_config {

manifests/daemon.pp

+5-5
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@
7575
Hash[String[1], Scalar] $env_vars = {},
7676
Stdlib::Absolutepath $env_file_path = $prometheus::env_file_path,
7777
Optional[String[1]] $extract_command = $prometheus::extract_command,
78-
Stdlib::Absolutepath $extract_path = '/opt',
79-
Stdlib::Absolutepath $archive_bin_path = "/opt/${name}-${version}.${os}-${arch}/${name}",
78+
Stdlib::Absolutepath $extract_path = $prometheus::basepath,
79+
Stdlib::Absolutepath $archive_bin_path = "${prometheus::basepath}/${name}-${version}.${os}-${arch}/${name}",
8080
Boolean $export_scrape_job = false,
8181
Stdlib::Host $scrape_host = $facts['networking']['fqdn'],
8282
Optional[Stdlib::Port] $scrape_port = undef,
@@ -89,17 +89,17 @@
8989
case $install_method {
9090
'url': {
9191
if $download_extension == '' {
92-
file { "/opt/${name}-${version}.${os}-${arch}":
92+
file { "${prometheus::basepath}/${name}-${version}.${os}-${arch}":
9393
ensure => directory,
9494
owner => 'root',
9595
group => 0, # 0 instead of root because OS X uses "wheel".
9696
mode => '0755',
9797
}
98-
-> archive { "/opt/${name}-${version}.${os}-${arch}/${name}":
98+
-> archive { "${prometheus::basepath}/${name}-${version}.${os}-${arch}/${name}":
9999
ensure => present,
100100
source => $real_download_url,
101101
checksum_verify => false,
102-
before => File["/opt/${name}-${version}.${os}-${arch}/${name}"],
102+
before => File["${prometheus::basepath}/${name}-${version}.${os}-${arch}/${name}"],
103103
proxy_server => $proxy_server,
104104
proxy_type => $proxy_type,
105105
}

manifests/dellhw_exporter.pp

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
# @param version
4747
# The binary release version
4848
# @param omreport_path
49-
# The file path to the omReport executable (default "/opt/dell/srvadmin/bin/omreport")
49+
# The file path to the omReport executable (default "/opt/prometheus/dell/srvadmin/bin/omreport")
5050
# @param scrape_ipadress
5151
# The ip address that the exporter will to listen to (default '')
5252
# @param proxy_server
@@ -84,7 +84,7 @@
8484
String[1] $scrape_job_name = 'dellhw',
8585
Optional[Hash] $scrape_job_labels = undef,
8686
Optional[String[1]] $bin_name = undef,
87-
Stdlib::Unixpath $omreport_path = '/opt/dell/srvadmin/bin/omreport',
87+
Stdlib::Unixpath $omreport_path = "${prometheus::basepath}/dell/srvadmin/bin/omreport",
8888
Optional[String[1]] $proxy_server = undef,
8989
Optional[Enum['none', 'http', 'https', 'ftp']] $proxy_type = undef,
9090
) inherits prometheus {
@@ -127,7 +127,7 @@
127127
scrape_job_name => $scrape_job_name,
128128
scrape_job_labels => $scrape_job_labels,
129129
bin_name => $bin_name,
130-
archive_bin_path => "/opt/dellhw_exporter-${version}.${os}-${arch}/dellhw_exporter",
130+
archive_bin_path => "${prometheus::basepath}/dellhw_exporter-${version}.${os}-${arch}/dellhw_exporter",
131131
proxy_server => $proxy_server,
132132
proxy_type => $proxy_type,
133133
}

manifests/init.pp

+18
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@
307307
Boolean $include_default_scrape_configs = true,
308308
Optional[String[1]] $proxy_server = undef,
309309
Optional[Enum['none', 'http', 'https', 'ftp']] $proxy_type = undef,
310+
Optional[Boolean] $clean_url_releases = false,
310311
) {
311312
case $arch {
312313
'x86_64', 'amd64': { $real_arch = 'amd64' }
@@ -321,6 +322,23 @@
321322
}
322323
}
323324

325+
if $clean_url_releases {
326+
$basepath = '/opt/prometheus'
327+
328+
file { $basepath:
329+
ensure => directory,
330+
owner => 'root',
331+
group => 'root',
332+
mode => '0755',
333+
backup => false,
334+
force => true,
335+
purge => true,
336+
recurse => true,
337+
}
338+
} else {
339+
$basepath = '/opt'
340+
}
341+
324342
if $manage_prometheus_server {
325343
include prometheus::server
326344
}

manifests/install.pp

+7-7
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,25 @@
1919
archive { "/tmp/prometheus-${prometheus::server::version}.${prometheus::server::download_extension}":
2020
ensure => present,
2121
extract => true,
22-
extract_path => '/opt',
22+
extract_path => $prometheus::basepath,
2323
source => $prometheus::server::real_download_url,
2424
checksum_verify => false,
25-
creates => "/opt/prometheus-${prometheus::server::version}.${prometheus::server::os}-${prometheus::server::real_arch}/prometheus",
25+
creates => "${prometheus::basepath}/prometheus-${prometheus::server::version}.${prometheus::server::os}-${prometheus::server::real_arch}/prometheus",
2626
cleanup => true,
2727
extract_command => $prometheus::extract_command,
2828
}
2929
-> file {
30-
"/opt/prometheus-${prometheus::server::version}.${prometheus::server::os}-${prometheus::server::real_arch}/prometheus":
30+
"${prometheus::basepath}/prometheus-${prometheus::server::version}.${prometheus::server::os}-${prometheus::server::real_arch}/prometheus":
3131
owner => 'root',
3232
group => 0, # 0 instead of root because OS X uses "wheel".
3333
mode => '0555';
3434
"${prometheus::server::bin_dir}/prometheus":
3535
ensure => link,
3636
notify => $prometheus::server::notify_service,
37-
target => "/opt/prometheus-${prometheus::server::version}.${prometheus::server::os}-${prometheus::server::real_arch}/prometheus";
37+
target => "${prometheus::basepath}/prometheus-${prometheus::server::version}.${prometheus::server::os}-${prometheus::server::real_arch}/prometheus";
3838
"${prometheus::server::bin_dir}/promtool":
3939
ensure => link,
40-
target => "/opt/prometheus-${prometheus::server::version}.${prometheus::server::os}-${prometheus::server::real_arch}/promtool";
40+
target => "${prometheus::basepath}/prometheus-${prometheus::server::version}.${prometheus::server::os}-${prometheus::server::real_arch}/promtool";
4141
$prometheus::server::shared_dir:
4242
ensure => directory,
4343
owner => $prometheus::server::user,
@@ -46,11 +46,11 @@
4646
"${prometheus::server::shared_dir}/consoles":
4747
ensure => link,
4848
notify => $prometheus::server::notify_service,
49-
target => "/opt/prometheus-${prometheus::server::version}.${prometheus::server::os}-${prometheus::server::real_arch}/consoles";
49+
target => "${prometheus::basepath}/prometheus-${prometheus::server::version}.${prometheus::server::os}-${prometheus::server::real_arch}/consoles";
5050
"${prometheus::server::shared_dir}/console_libraries":
5151
ensure => link,
5252
notify => $prometheus::server::notify_service,
53-
target => "/opt/prometheus-${prometheus::server::version}.${prometheus::server::os}-${prometheus::server::real_arch}/console_libraries";
53+
target => "${prometheus::basepath}/prometheus-${prometheus::server::version}.${prometheus::server::os}-${prometheus::server::real_arch}/console_libraries";
5454
}
5555
}
5656
'package': {

manifests/ipsec_exporter.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
}
8989
else {
9090
$release = "v${version}"
91-
$archive_bin_path = "/opt/ipsec_exporter-v${version}.${os}-${arch}"
91+
$archive_bin_path = "${prometheus::basepath}/ipsec_exporter-v${version}.${os}-${arch}"
9292
}
9393
$real_download_url = pick($download_url,"${download_url_base}/download/v${version}/${package_name}-${release}.${os}-${arch}.${download_extension}")
9494

manifests/mongodb_exporter.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
if versioncmp($version, '0.7.0') < 0 or versioncmp($version, '0.20.4') >= 0 {
9696
$archive_bin_path = undef # use default
9797
} else {
98-
$archive_bin_path = '/opt/mongodb_exporter'
98+
$archive_bin_path = "${prometheus::basepath}/mongodb_exporter"
9999
}
100100

101101
$notify_service = $restart_on_change ? {

manifests/nginx_prometheus_exporter.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
# nginx_prometheus_exporter lacks currently as of version 0.9.0
105105
# TODO: patch prometheus::daemon to support custom extract directories
106106
$real_install_method = 'none'
107-
$install_dir = "/opt/${package_name}-${version}.${os}-${arch}"
107+
$install_dir = "${prometheus::basepath}/${package_name}-${version}.${os}-${arch}"
108108
file { $install_dir:
109109
ensure => 'directory',
110110
owner => 'root',

manifests/openldap_exporter.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
if versioncmp($version, '2.2.1') >= 0 {
8787
$real_download_extension = 'gz'
8888
$real_download_url = pick($download_url,"${download_url_base}/download/${release}/${package_name}-${os}-${prometheus::real_arch}.gz")
89-
$extract_path = "/opt/openldap_exporter-${version}.${os}-${prometheus::real_arch}"
89+
$extract_path = "${prometheus::basepath}/openldap_exporter-${version}.${os}-${prometheus::real_arch}"
9090
$archive_bin_path = "${extract_path}/openldap_exporter-${os}-${prometheus::real_arch}"
9191
$extract_command = "gzip -cd %s > ${archive_bin_path}"
9292
file { $extract_path:

manifests/php_fpm_exporter.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
# php-fpm_exporter lacks currently as of version 2.0.4
106106
# TODO: patch prometheus::daemon to support custom extract directories
107107
$real_install_method = 'none'
108-
$install_dir = "/opt/${package_name}-${version}.${os}-${arch}"
108+
$install_dir = "${prometheus::basepath}/${package_name}-${version}.${os}-${arch}"
109109
file { $install_dir:
110110
ensure => 'directory',
111111
owner => 'root',

manifests/postgres_exporter.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@
138138
# postgres_exporter lacks.
139139
# TODO: patch prometheus::daemon to support custom extract directories
140140
$exporter_install_method = 'none'
141-
$install_dir = "/opt/${service_name}-${version}.${os}-${arch}"
141+
$install_dir = "${prometheus::basepath}/${service_name}-${version}.${os}-${arch}"
142142
file { $install_dir:
143143
ensure => 'directory',
144144
owner => 'root',

manifests/puppetdb_exporter.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
scrape_job_name => $scrape_job_name,
124124
scrape_job_labels => $scrape_job_labels,
125125
bin_name => $bin_name,
126-
archive_bin_path => "/opt/prometheus-puppetdb-exporter-${version}.${os}-${arch}/prometheus-puppetdb-exporter",
126+
archive_bin_path => "${prometheus::basepath}/prometheus-puppetdb-exporter-${version}.${os}-${arch}/prometheus-puppetdb-exporter",
127127
proxy_server => $proxy_server,
128128
proxy_type => $proxy_type,
129129
}

manifests/pushprox_client.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
install_method => $install_method,
9797
version => $version,
9898
download_extension => $download_extension,
99-
archive_bin_path => "/opt/PushProx-${version}.${os}-${arch}/pushprox-client",
99+
archive_bin_path => "${prometheus::basepath}/PushProx-${version}.${os}-${arch}/pushprox-client",
100100
os => $os,
101101
arch => $arch,
102102
real_download_url => $real_download_url,

manifests/pushprox_proxy.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
install_method => $install_method,
9191
version => $version,
9292
download_extension => $download_extension,
93-
archive_bin_path => "/opt/PushProx-${version}.${os}-${arch}/pushprox-proxy",
93+
archive_bin_path => "${prometheus::basepath}/PushProx-${version}.${os}-${arch}/pushprox-proxy",
9494
os => $os,
9595
arch => $arch,
9696
real_download_url => $real_download_url,

manifests/redis_exporter.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
# redis_exporter lacks before version 1.0.0
111111
# TODO: patch prometheus::daemon to support custom extract directories
112112
$real_install_method = 'none'
113-
$install_dir = "/opt/${service_name}-${version}.${os}-${arch}"
113+
$install_dir = "${prometheus::basepath}/${service_name}-${version}.${os}-${arch}"
114114
file { $install_dir:
115115
ensure => 'directory',
116116
owner => 'root',

manifests/snmp_exporter.pp

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,12 @@
105105
}
106106

107107
$_source = $config_template ? {
108-
'' => "file:/opt/snmp_exporter-${version}.${os}-${arch}/snmp.yml",
108+
'' => "file:${prometheus::basepath}/snmp_exporter-${version}.${os}-${arch}/snmp.yml",
109109
default => undef,
110110
}
111111

112112
$_require = $config_template ? {
113-
'' => File["/opt/snmp_exporter-${version}.${os}-${arch}/snmp_exporter"],
113+
'' => File["${prometheus::basepath}/snmp_exporter-${version}.${os}-${arch}/snmp_exporter"],
114114
default => undef,
115115
}
116116

manifests/ssl_exporter.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
], ' ')
114114

115115
# SSL exporter is not packaged into a directory
116-
$extract_path = "/opt/${service_name}-${version}.${os}-${arch}"
116+
$extract_path = "${prometheus::basepath}/${service_name}-${version}.${os}-${arch}"
117117
file { $extract_path:
118118
ensure => 'directory',
119119
owner => 'root',

0 commit comments

Comments
 (0)