Skip to content

Commit

Permalink
issue voxpupuli#306: Fix broken startup scripts
Browse files Browse the repository at this point in the history
Our init scripts sometimes contain a trailing `\` after the last
argument. Some might lead to wrong parsing.

Fixes voxpupuli#306
Replaces voxpupuli#307
  • Loading branch information
dubcl authored and bastelfreak committed May 20, 2019
1 parent 53939ce commit 35cb434
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion data/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ prometheus::service_ensure: 'running'
prometheus::manage_service: true
prometheus::restart_on_change: true
prometheus::init_style: '%{facts.service_provider}'
prometheus::extra_options: ''
prometheus::extra_options: ~
prometheus::download_url: ~
prometheus::arch: '%{facts.architecture}'
prometheus::manage_group: true
Expand Down
17 changes: 14 additions & 3 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,19 @@
if $prometheus::server::remote_write_configs != [] {
fail('remote_write_configs requires prometheus 2.X')
}
$daemon_flags = [
$_daemon_flags = [
'-log.format logger:stdout',
"-config.file=${prometheus::server::config_dir}/${prometheus::server::configname}",
"-storage.local.path=${prometheus::server::localstorage}",
"-storage.local.retention=${prometheus::server::storage_retention}",
"-web.console.templates=${prometheus::shared_dir}/consoles",
"-web.console.libraries=${prometheus::shared_dir}/console_libraries",
]
if $prometheus::server::extra_options {
$daemon_flags = $_daemon_flags + $prometheus::server::extra_options
} else {
$daemon_flags = $_daemon_flags
}
} else {
# helper variable indicating prometheus version, so we can use on this information in the template
$prometheus_v2 = true
Expand All @@ -32,10 +37,16 @@
"--web.console.templates=${prometheus::server::shared_dir}/consoles",
"--web.console.libraries=${prometheus::server::shared_dir}/console_libraries",
]

if $prometheus::server::external_url {
$daemon_flags = $daemon_flags_basic + "--web.external-url=${prometheus::server::external_url}"
$_daemon_flags = $daemon_flags_basic + "--web.external-url=${prometheus::server::external_url}"
} else {
$_daemon_flags = $daemon_flags_basic
}
if $prometheus::server::extra_options {
$daemon_flags = $_daemon_flags + $prometheus::server::extra_options
} else {
$daemon_flags = $daemon_flags_basic
$daemon_flags = $_daemon_flags
}
}

Expand Down
2 changes: 1 addition & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
Boolean $manage_service,
Boolean $restart_on_change,
String $init_style,
String $extra_options,
Optional[String[1]] $extra_options,
Optional[String] $download_url,
String $arch,
Boolean $manage_group,
Expand Down
2 changes: 1 addition & 1 deletion manifests/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
Boolean $manage_service = $prometheus::manage_service,
Boolean $restart_on_change = $prometheus::restart_on_change,
String $init_style = $prometheus::init_style,
String $extra_options = $prometheus::extra_options,
Optional[String[1]] $extra_options = $prometheus::extra_options,
Hash $config_hash = $prometheus::config_hash,
Hash $config_defaults = $prometheus::config_defaults,
String $os = $prometheus::os,
Expand Down
4 changes: 2 additions & 2 deletions spec/fixtures/files/prometheus2.systemd
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# THIS FILE IS MANAGED BY PUPPET
[Unit]
Description=Prometheus Monitoring framework
Wants=basic.target
Expand All @@ -11,8 +12,7 @@ ExecStart=/usr/local/bin/prometheus \
--storage.tsdb.path=/var/lib/prometheus \
--storage.tsdb.retention=360h \
--web.console.templates=/usr/local/share/prometheus/consoles \
--web.console.libraries=/usr/local/share/prometheus/console_libraries \

--web.console.libraries=/usr/local/share/prometheus/console_libraries
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=always
Expand Down
3 changes: 1 addition & 2 deletions spec/fixtures/files/prometheus2.upstart
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ script
--storage.tsdb.path=/var/lib/prometheus \
--storage.tsdb.retention=360h \
--web.console.templates=/usr/local/share/prometheus/consoles \
--web.console.libraries=/usr/local/share/prometheus/console_libraries \

--web.console.libraries=/usr/local/share/prometheus/console_libraries
end script

respawn
Expand Down
4 changes: 2 additions & 2 deletions templates/prometheus.systemd.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# THIS FILE IS MANAGED BY PUPPET
[Unit]
Description=Prometheus Monitoring framework
Wants=basic.target
Expand All @@ -7,8 +8,7 @@ After=basic.target network.target
User=<%= scope.lookupvar('prometheus::server::user') %>
Group=<%= scope.lookupvar('prometheus::server::group') %>
ExecStart=<%= scope.lookupvar('prometheus::server::bin_dir') %>/prometheus \
<%= @daemon_flags.join(" \\\n ") %> \
<%= scope.lookupvar('prometheus::server::extra_options') %>
<%= @daemon_flags.join(" \\\n ") %>
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=always
Expand Down
3 changes: 1 addition & 2 deletions templates/prometheus.upstart.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ script
[ -e $DEFAULTS ] && . $DEFAULTS

export GOMAXPROCS=${GOMAXPROCS:-2}
exec start-stop-daemon --chuid $USER --group $GROUP --pidfile $PID_FILE --exec $PROMETHEUS --start -- <%= @daemon_flags.join(" \\\n ") %> \
<%= scope.lookupvar('prometheus::server::extra_options') %>
exec start-stop-daemon --chuid $USER --group $GROUP --pidfile $PID_FILE --exec $PROMETHEUS --start -- <%= @daemon_flags.join(" \\\n ") %>
end script

respawn
Expand Down

0 comments on commit 35cb434

Please sign in to comment.