Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Debian package configuration #303

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions manifests/blackbox_exporter.pp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
Boolean $manage_user = true,
String[1] $os = downcase($facts['kernel']),
String $extra_options = '',
Hash[String, Scalar] $env_vars = {},
Optional[String] $download_url = undef,
String[1] $config_mode = $prometheus::config_mode,
String[1] $arch = $prometheus::real_arch,
Expand Down Expand Up @@ -136,6 +137,7 @@
manage_group => $manage_group,
options => $options,
init_style => $init_style,
env_vars => $env_vars,
service_ensure => $service_ensure,
service_enable => $service_enable,
manage_service => $manage_service,
Expand Down
12 changes: 11 additions & 1 deletion manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,15 @@
default => undef,
}

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

case $prometheus::server::init_style { # lint:ignore:case_without_default
'upstart': {
file { '/etc/init/prometheus.conf':
Expand All @@ -182,9 +191,10 @@
content => epp("${module_name}/prometheus.systemd.epp", {
'user' => $prometheus::server::user,
'group' => $prometheus::server::group,
'daemon_flags' => $daemon_flags,
'daemon_flags' => $daemon_flags.sort,
'max_open_files' => $max_open_files,
'bin_dir' => $prometheus::server::bin_dir,
'env_file_path' => $prometheus::server::env_file_path,
}),
notify => $notify,
}
Expand Down
2 changes: 2 additions & 0 deletions manifests/postfix_exporter.pp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
# exporter configuration
String $extra_options = '--systemd.enable --systemd.unit=\'postfix.service\' --postfix.logfile_path=\'\'',
Boolean $restart_on_change = true,
Hash[String, Scalar] $env_vars = {},

# scrape job configuration
Boolean $export_scrape_job = false,
Expand Down Expand Up @@ -113,6 +114,7 @@
manage_group => $manage_group,
options => $extra_options,
init_style => $init_style,
env_vars => $env_vars,
service_ensure => $service_ensure,
service_enable => $service_enable,
manage_service => $manage_service,
Expand Down
18 changes: 15 additions & 3 deletions spec/classes/prometheus_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,21 @@
}

it {
is_expected.to contain_systemd__unit_file('prometheus.service').with(
'content' => File.read(fixtures('files', "prometheus#{prom_major}.systemd"))
)
if ['centos-7-x86_64', 'redhat-7-x86_64'].include?(os)
is_expected.to contain_file('/etc/sysconfig/prometheus').with(
'content' => File.read(fixtures('files', 'prometheus.default'))
)
is_expected.to contain_systemd__unit_file('prometheus.service').with(
'content' => File.read(fixtures('files', 'prometheus-redhat.systemd'))
)
elsif ['debian-8-x86_64', 'debian-9-x86_64', 'ubuntu-16.04-x86_64', 'ubuntu-18.04-x86_64', 'archlinux-4-x86_64'].include?(os)
is_expected.to contain_file('/etc/default/prometheus').with(
'content' => File.read(fixtures('files', 'prometheus.default'))
)
is_expected.to contain_systemd__unit_file('prometheus.service').with(
'content' => File.read(fixtures('files', 'prometheus-debian.systemd'))
)
end
}
describe 'max_open_files' do
context 'by default' do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@ After=basic.target network.target
[Service]
User=prometheus
Group=prometheus
ExecStart=/usr/local/bin/prometheus \
--config.file=/etc/prometheus/prometheus.yaml \
--web.console.templates=/usr/local/share/prometheus/consoles \
--web.console.libraries=/usr/local/share/prometheus/console_libraries \
--storage.tsdb.path=/var/lib/prometheus \
--storage.tsdb.retention=360h
EnvironmentFile=/etc/default/prometheus
ExecStart=/usr/local/bin/prometheus $ARGS
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=always
Expand Down
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 @@ -6,13 +7,8 @@ After=basic.target network.target
[Service]
User=prometheus
Group=prometheus
ExecStart=/usr/local/bin/prometheus \
-config.file=/etc/prometheus/prometheus.yaml \
-web.console.templates=/usr/local/share/prometheus/consoles \
-web.console.libraries=/usr/local/share/prometheus/console_libraries \
-storage.local.path=/var/lib/prometheus \
-storage.local.retention=360h \

EnvironmentFile=/etc/sysconfig/prometheus
ExecStart=/usr/local/bin/prometheus $ARGS
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=always
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/files/prometheus.default
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ARGS='--config.file=/etc/prometheus/prometheus.yaml --storage.tsdb.path=/var/lib/prometheus --storage.tsdb.retention=360h --web.console.libraries=/usr/local/share/prometheus/console_libraries --web.console.templates=/usr/local/share/prometheus/consoles'
6 changes: 6 additions & 0 deletions templates/prometheus.systemd.epp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Array[String] $daemon_flags,
Optional[Integer] $max_open_files,
Stdlib::Absolutepath $bin_dir,
Optional[String] $env_file_path,
| -%>
# THIS FILE IS MANAGED BY PUPPET
[Unit]
Expand All @@ -13,8 +14,13 @@ After=basic.target network.target
[Service]
User=<%= $user %>
Group=<%= $group %>
<% if $env_file_path { -%>
EnvironmentFile=<%= $env_file_path %>/prometheus
ExecStart=<%= $bin_dir %>/prometheus $ARGS
<% } else { -%>
ExecStart=<%= $bin_dir %>/prometheus \
<%= $daemon_flags.join(" \\\n ") %>
<% } -%>
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=always
Expand Down