Skip to content

Commit

Permalink
deploy the "defaults" file correctly so that changes take effect
Browse files Browse the repository at this point in the history
Without this change, when the install_method is set to `package`, the
various `prometheus::server` settings will never do anything because
we stop touching the systemd config file.

By default, the Debian systemd.service file has this entry:

EnvironmentFile=/etc/default/prometheus
ExecStart=/usr/bin/prometheus $ARGS

... which makes it use the ARGS define in the "default" config
file. We harmonize our systemd config and init.d files to sync up with
that file instead of rewriting the startup file.

Closes: #323.
  • Loading branch information
anarcat committed Jun 14, 2019
1 parent 0d0f157 commit 4146844
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@
$systemd_notify = Exec['prometheus-systemd-reload']
}

if $prometheus::env_file_path != undef {
file { "${prometheus::env_file_path}/prometheus":
mode => '0644',
owner => 'root',
group => '0', # Darwin uses wheel
content => "ARGS='${join($daemon_flags, ' ')}'\n",
}
}

case $prometheus::server::init_style {
'upstart' : {
file { '/etc/init/prometheus.conf':
Expand Down
4 changes: 4 additions & 0 deletions templates/prometheus.debian.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ DESC="Prometheus monitoring framework"
NAME=prometheus
DAEMON=<%= scope.lookupvar('prometheus::server::bin_dir') %>/$NAME
PIDFILE=/var/run/$NAME/$NAME.pid
<% if scope.lookupvar('prometheus::server::env_file_path') %>
DAEMON_ARGS=''
<% else %>
DAEMON_ARGS="<%= @daemon_flags.join("\n ") %>
<%= scope.lookupvar('prometheus::server::extra_options') %>"
<% end %>
USER=<%= scope.lookupvar('prometheus::server::user') %>
SCRIPTNAME=/etc/init.d/$NAME

Expand Down
5 changes: 5 additions & 0 deletions templates/prometheus.systemd.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ After=basic.target network.target
[Service]
User=<%= scope.lookupvar('prometheus::server::user') %>
Group=<%= scope.lookupvar('prometheus::server::group') %>
<% if scope.lookupvar('prometheus::server::env_file_path') %>
EnvironmentFile=<%= scope.lookupvar('prometheus::server::env_file_path') %>/prometheus
ExecStart=<%= scope.lookupvar('prometheus::server::bin_dir') %>/prometheus $ARGS
<% else %>
ExecStart=<%= scope.lookupvar('prometheus::server::bin_dir') %>/prometheus \
<%= @daemon_flags.join(" \\\n ") %>
<% end %>
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=always
Expand Down

0 comments on commit 4146844

Please sign in to comment.