Changeset View
Changeset View
Standalone View
Standalone View
site-modules/profile/manifests/prometheus/elasticsearch.pp
# Deployment of prometheus elasticsearch exporter | # Deployment of prometheus elasticsearch exporter | ||||
class profile::prometheus::elasticsearch { | class profile::prometheus::elasticsearch { | ||||
include profile::prometheus::base | include profile::prometheus::base | ||||
$version = lookup('prometheus::elasticsearch::exporter::version') | $version = lookup('prometheus::elasticsearch::exporter::version') | ||||
$archive_url = "https://github.com/vvanholl/elasticsearch-prometheus-exporter/releases/download/${version}/prometheus-exporter-${version}.zip" | $archive_url = "https://github.com/vvanholl/elasticsearch-prometheus-exporter/releases/download/${version}/prometheus-exporter-${version}.zip" | ||||
$archive_path = '/usr/share/elasticsearch/plugins/prometheus-exporter' | $plugin_path = '/usr/share/elasticsearch/plugins/prometheus-exporter' | ||||
file { $archive_path: | exec {'cleanup prometheus exporter plugin': | ||||
creates => "${plugin_path}/prometheus-exporter-${version}.jar", | |||||
command => "/usr/bin/rm -rf ${plugin_path}", | |||||
} -> file { $plugin_path: | |||||
ensure => directory, | ensure => directory, | ||||
owner => 'elasticsearch', | owner => 'elasticsearch', | ||||
group => 'elasticsearch', | group => 'elasticsearch', | ||||
mode => '0755', | mode => '0755', | ||||
require => Package['elasticsearch'] | require => Package['elasticsearch'] | ||||
} | } | ||||
-> archive { 'prometheus-elasticsearch-exporter': | -> archive { 'prometheus-elasticsearch-exporter': | ||||
path => "/tmp/prometheus-exporter-${version}.zip", | path => "/tmp/prometheus-exporter-${version}.zip", | ||||
source => $archive_url, | source => $archive_url, | ||||
extract => true, | extract => true, | ||||
extract_path => '/usr/share/elasticsearch/plugins/prometheus-exporter', | extract_path => $plugin_path, | ||||
creates => "${archive_path}/plugin-descriptor.properties", | creates => "${plugin_path}/prometheus-exporter-${version}.jar", | ||||
cleanup => true, | cleanup => true, | ||||
user => 'root', | user => 'root', | ||||
group => 'root', | group => 'root', | ||||
require => Package['elasticsearch'], | require => [ | ||||
Package['elasticsearch'], | |||||
], | |||||
} | } | ||||
Archive['prometheus-elasticsearch-exporter'] ~> Service['elasticsearch'] | Archive['prometheus-elasticsearch-exporter'] ~> Service['elasticsearch'] | ||||
} | } |