diff --git a/manifests/config.pp b/manifests/config.pp index ef5a0083a..50f25ad33 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -9,6 +9,21 @@ ) { if $prometheus::init_style { + if( versioncmp($::prometheus::version, '2.0.0') < 0 ){ + $daemon_flags = [ + "-config.file=${::prometheus::config_dir}/prometheus.yaml", + "-storage.local.path=${::prometheus::localstorage}", + "-web.console.templates=${::prometheus::shared_dir}/consoles", + "-web.console.libraries=${::prometheus::shared_dir}/console_libraries", + ] + } else { + $daemon_flags = [ + "--config.file=${::prometheus::config_dir}/prometheus.yaml", + "--storage.tsdb.path=${::prometheus::localstorage}", + "--web.console.templates=${::prometheus::shared_dir}/consoles", + "--web.console.libraries=${::prometheus::shared_dir}/console_libraries", + ] + } case $prometheus::init_style { 'upstart' : { diff --git a/templates/prometheus.debian.erb b/templates/prometheus.debian.erb index d4a2e7022..47dfa47e5 100644 --- a/templates/prometheus.debian.erb +++ b/templates/prometheus.debian.erb @@ -18,10 +18,7 @@ DESC="Prometheus monitoring framework" NAME=prometheus DAEMON=<%= scope.lookupvar('prometheus::bin_dir') %>/$NAME PIDFILE=/var/run/$NAME/$NAME.pid -DAEMON_ARGS=" -config.file=<%= scope.lookupvar('prometheus::config_dir')+'/prometheus.yaml' %> - -storage.local.path=<%= scope.lookupvar('prometheus::localstorage')%> - -web.console.templates=<%= scope.lookupvar('prometheus::shared_dir') %>/consoles - -web.console.libraries=<%= scope.lookupvar('prometheus::shared_dir') %>/console_libraries +DAEMON_ARGS="<%= @daemon_flags.join("\n ") %> <%= scope.lookupvar('prometheus::extra_options') %>" USER=<%= scope.lookupvar('prometheus::user') %> SCRIPTNAME=/etc/init.d/$NAME diff --git a/templates/prometheus.launchd.erb b/templates/prometheus.launchd.erb index fffe37db8..c52b2f334 100644 --- a/templates/prometheus.launchd.erb +++ b/templates/prometheus.launchd.erb @@ -16,14 +16,9 @@ <%= scope.lookupvar('prometheus::bin_dir') %>/prometheus agent - -config.file= - <%= scope.lookupvar('prometheus::config_dir')+'/prometheus.yaml' %> - -storage.local.path= - <%= scope.lookupvar('prometheus::localstorage')%> - -web.console.templates= - <%= scope.lookupvar('prometheus::shared_dir') %>/consoles - -web.console.libraries= - <%= scope.lookupvar('prometheus::shared_dir') %>/console_libraries + <%- daemon_flags.each |flag| do -%> + <%= flag %> + <%- end -%> <% require 'shellwords' %> <% for extra_option in Shellwords.split(scope.lookupvar('prometheus::extra_options')) %> <%= extra_option %> diff --git a/templates/prometheus.sles.erb b/templates/prometheus.sles.erb index 667e1145a..f812346c5 100644 --- a/templates/prometheus.sles.erb +++ b/templates/prometheus.sles.erb @@ -36,10 +36,7 @@ case "$1" in echo -n "Starting prometheus " ## Start daemon with startproc(8). If this fails ## the return value is set appropriately by startproc. - startproc $PROMETHEUS_BIN -config.file="$CONFIG_FILE" \ - -storage.local.path=<%= scope.lookupvar('prometheus::localstorage')%> \ - -web.console.templates=<%= scope.lookupvar('prometheus::shared_dir') %>/consoles \ - -web.console.libraries=<%= scope.lookupvar('prometheus::shared_dir') %>/console_libraries \ + startproc $PROMETHEUS_BIN <%= @daemon_flags.join("\n\\ ") %> \ <%= scope.lookupvar('prometheus::extra_options') %> >> "$LOG_FILE" # Remember status and be verbose diff --git a/templates/prometheus.systemd.erb b/templates/prometheus.systemd.erb index 0a845c4fa..0b347fae0 100644 --- a/templates/prometheus.systemd.erb +++ b/templates/prometheus.systemd.erb @@ -7,10 +7,7 @@ After=basic.target network.target User=<%= scope.lookupvar('prometheus::user') %> Group=<%= scope.lookupvar('prometheus::group') %> ExecStart=<%= scope.lookupvar('prometheus::bin_dir') %>/prometheus \ - -config.file=<%= scope.lookupvar('prometheus::config_dir')+'/prometheus.yaml' %>\ - -storage.local.path=<%= scope.lookupvar('prometheus::localstorage')%> \ - -web.console.templates=<%= scope.lookupvar('prometheus::shared_dir') %>/consoles \ - -web.console.libraries=<%= scope.lookupvar('prometheus::shared_dir') %>/console_libraries \ + <%= @daemon_flags.join("\n\\ ") %> \ <%= scope.lookupvar('prometheus::extra_options') %> ExecReload=/bin/kill -HUP $MAINPID KillMode=process diff --git a/templates/prometheus.sysv.erb b/templates/prometheus.sysv.erb index 4d62b75d9..123a5c5ca 100644 --- a/templates/prometheus.sysv.erb +++ b/templates/prometheus.sysv.erb @@ -52,10 +52,7 @@ start() { [ -f $PID_FILE ] && rm $PID_FILE daemon --user=<%= scope.lookupvar('prometheus::user') %> \ --pidfile="$PID_FILE" \ - "$DAEMON" -log.format logger:stdout -config.file="$CONFIG" \ - -storage.local.path=<%= scope.lookupvar('prometheus::localstorage')%> \ - -web.console.templates=<%= scope.lookupvar('prometheus::shared_dir') %>/consoles \ - -web.console.libraries=<%= scope.lookupvar('prometheus::shared_dir') %>/console_libraries \ + "$DAEMON" -log.format logger:stdout <%= @daemon_flags.join("\n\\ ") %> \ <%= scope.lookupvar('prometheus::extra_options') %> >> "$LOG_FILE" & retcode=$? mkpidfile diff --git a/templates/prometheus.upstart.erb b/templates/prometheus.upstart.erb index 1d8b2ddc0..678d039de 100644 --- a/templates/prometheus.upstart.erb +++ b/templates/prometheus.upstart.erb @@ -23,10 +23,7 @@ script [ -e $DEFAULTS ] && . $DEFAULTS export GOMAXPROCS=${GOMAXPROCS:-2} - exec start-stop-daemon -c $USER -g $GROUP -p $PID_FILE -x $PROMETHEUS -S -- -config.file=$CONFIG \ - -storage.local.path=<%= scope.lookupvar('prometheus::localstorage')%> \ - -web.console.templates=<%= scope.lookupvar('prometheus::shared_dir') %>/consoles \ - -web.console.libraries=<%= scope.lookupvar('prometheus::shared_dir') %>/console_libraries \ + exec start-stop-daemon -c $USER -g $GROUP -p $PID_FILE -x $PROMETHEUS -S -- <%= @daemon_flags.join("\n\\ ") %> \ <%= scope.lookupvar('prometheus::extra_options') %> end script