Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

puppet: Move prometheus to external_dep.

Alex Vandiverbb5a2c8138a7
diff --git a/puppet/zulip_ops/files/supervisor/conf.d/prometheus.conf b/puppet/zulip_ops/files/supervisor/conf.d/prometheus.conf
deleted file mode 100644
index 8af5cafdf32..00000000000
--- a/puppet/zulip_ops/files/supervisor/conf.d/prometheus.conf
+++ /dev/null
@@ -1,9 +0,0 @@
-[program:prometheus]
-command=/srv/prometheus/prometheus --storage.tsdb.path="/var/lib/prometheus" --config.file="/etc/prometheus/prometheus.yaml" --web.listen-address="127.0.0.1:9090" --storage.tsdb.retention.time=1y
-directory=/srv/prometheus
-priority=10
-autostart=true
-autorestart=true
-user=prometheus
-redirect_stderr=true
-stdout_logfile=/var/log/prometheus.log
diff --git a/puppet/zulip_ops/manifests/profile/prometheus_server.pp b/puppet/zulip_ops/manifests/profile/prometheus_server.pp
index ab59eb21d7d..c6da0871e4b 100644
--- a/puppet/zulip_ops/manifests/profile/prometheus_server.pp
+++ b/puppet/zulip_ops/manifests/profile/prometheus_server.pp
@@ -7,44 +7,34 @@ class zulip_ops::profile::prometheus_server {
include zulip_ops::prometheus::base
$version = '2.27.1'
- zulip::sha256_tarball_to { 'prometheus':
- url => "https://github.com/prometheus/prometheus/releases/download/v${version}/prometheus-${version}.linux-${::architecture}.tar.gz",
- sha256 => 'ce637d0167d5e6d2561f3bd37e1c58fe8601e13e4e1ea745653c068f6e1317ae',
- install => {
- "prometheus-${version}.linux-${::architecture}/" => "/srv/prometheus-${version}/",
- },
- }
- file { '/srv/prometheus':
- ensure => 'link',
- target => "/srv/prometheus-${version}/",
- require => Zulip::Sha256_tarball_to['prometheus'],
+ $dir = "/srv/zulip-prometheus-${version}/"
+ $bin = "${dir}prometheus"
+ $data_dir = '/var/lib/prometheus'
+
+ zulip::external_dep { 'prometheus':
+ version => $version,
+ url => "https://github.com/prometheus/prometheus/releases/download/v${version}/prometheus-${version}.linux-${::architecture}.tar.gz",
+ sha256 => 'ce637d0167d5e6d2561f3bd37e1c58fe8601e13e4e1ea745653c068f6e1317ae',
+ tarball_prefix => "prometheus-${version}.linux-${::architecture}/",
+ bin => 'prometheus',
}
file { '/usr/local/bin/promtool':
ensure => 'link',
- target => '/srv/prometheus/promtool',
- require => File['/srv/prometheus'],
+ target => "${dir}promtool",
+ require => File[$dir],
+ }
+ # This was moved to an external dep in 2021/12, and the below can be
+ # removed once the prod server has taken the update.
+ file { '/srv/prometheus':
+ ensure => absent,
}
- file { '/var/lib/prometheus':
+ file { $data_dir:
ensure => directory,
owner => 'prometheus',
group => 'prometheus',
require => [ User[prometheus], Group[prometheus] ],
}
- file { "${zulip::common::supervisor_conf_dir}/prometheus.conf":
- ensure => file,
- require => [
- Package[supervisor],
- File['/srv/prometheus'],
- File['/var/lib/prometheus'],
- ],
- owner => 'root',
- group => 'root',
- mode => '0644',
- source => 'puppet:///modules/zulip_ops/supervisor/conf.d/prometheus.conf',
- notify => Service[supervisor],
- }
-
file { '/etc/prometheus':
ensure => directory,
owner => 'root',
@@ -59,4 +49,19 @@ class zulip_ops::profile::prometheus_server {
source => 'puppet:///modules/zulip_ops/prometheus/prometheus.yaml',
notify => Service[supervisor],
}
+
+ file { "${zulip::common::supervisor_conf_dir}/prometheus.conf":
+ ensure => file,
+ require => [
+ Package[supervisor],
+ File[$bin],
+ File[$data_dir],
+ File['/etc/prometheus/prometheus.yaml'],
+ ],
+ owner => 'root',
+ group => 'root',
+ mode => '0644',
+ content => template('zulip_ops/supervisor/conf.d/prometheus.conf.template.erb'),
+ notify => Service[supervisor],
+ }
}
diff --git a/puppet/zulip_ops/templates/supervisor/conf.d/prometheus.conf.template.erb b/puppet/zulip_ops/templates/supervisor/conf.d/prometheus.conf.template.erb
new file mode 100644
index 00000000000..0b13c8e8d48
--- /dev/null
+++ b/puppet/zulip_ops/templates/supervisor/conf.d/prometheus.conf.template.erb
@@ -0,0 +1,9 @@
+[program:prometheus]
+command=<%= @bin %> --storage.tsdb.path="<%= @data_dir %>" --config.file="/etc/prometheus/prometheus.yaml" --web.listen-address="127.0.0.1:9090" --storage.tsdb.retention.time=1y
+directory=<%= @dir %>
+priority=10
+autostart=true
+autorestart=true
+user=prometheus
+redirect_stderr=true
+stdout_logfile=/var/log/prometheus.log