Skip to content

Commit

Permalink
Merge pull request #412 from bastelfreak/arch6
Browse files Browse the repository at this point in the history
Arch Linux: Use prometheus unit file from package
  • Loading branch information
bastelfreak authored Jan 6, 2020
2 parents c7a4958 + d75b299 commit 7a87d62
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
2 changes: 2 additions & 0 deletions data/Archlinux.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---
prometheus::configname: 'prometheus.yml'
prometheus::server::init_style: 'none'
prometheus::version: '2.10.0'
prometheus::install_method: 'package'
prometheus::bin_dir: '/usr/bin'
Expand Down
37 changes: 30 additions & 7 deletions spec/classes/prometheus_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
facts.merge(os_specific_facts(facts))
end

configpath = if facts[:os]['name'] == 'Archlinux'
'/etc/prometheus/prometheus.yml'
else
'/etc/prometheus/prometheus.yaml'
end

[{ manage_prometheus_server: true, version: '2.0.0-rc.1', bin_dir: '/usr/local/bin', install_method: 'url', rule_files: ['/etc/prometheus/rules.d/*.rules'] }].each do |parameters|
context "with parameters #{parameters}" do
let(:params) do
Expand Down Expand Up @@ -104,7 +110,8 @@
'content' => File.read(fixtures('files', "prometheus#{prom_major}.sysv"))
)
}
elsif ['centos-7-x86_64', 'centos-8-x86_64', 'debian-8-x86_64', 'debian-9-x86_64', 'redhat-7-x86_64', 'redhat-8-x86_64', 'ubuntu-16.04-x86_64', 'ubuntu-18.04-x86_64', 'archlinux-5-x86_64'].include?(os)
elsif ['centos-7-x86_64', 'centos-8-x86_64', 'debian-8-x86_64', 'debian-9-x86_64', 'redhat-7-x86_64', 'redhat-8-x86_64', 'ubuntu-16.04-x86_64', 'ubuntu-18.04-x86_64'].include?(os)
# 'archlinux-5-x86_64' got removed from that list. It has systemd, but we use the repo packages and their shipped unit files.
# init_style = 'systemd'

it {
Expand Down Expand Up @@ -134,6 +141,9 @@
}
end
end
elsif os == 'archlinux-5-x86_64'

it { is_expected.not_to contain_systemd__unit_file('prometheus.service') }
else
it {
is_expected.to raise_error(Puppet::Error, %r{I don't know how to create an init script for style})
Expand All @@ -153,7 +163,7 @@
it {
is_expected.to contain_file('prometheus.yaml').with(
'ensure' => 'file',
'path' => '/etc/prometheus/prometheus.yaml',
'path' => configpath,
'owner' => 'root',
'group' => 'prometheus',
'mode' => '0640',
Expand Down Expand Up @@ -186,6 +196,21 @@
end
end

context 'with unit files from Puppet and not the packaged ones', if: facts[:os]['name'] == 'Archlinux' do
let :params do
{
manage_prometheus_server: true,
version: '2.0.0-rc.1',
rule_files: ['/etc/prometheus/rules.d/*.rules'],
init_style: 'systemd'
}
end

it { is_expected.not_to contain_class('systemd') }

it { is_expected.not_to contain_systemd__unit_file('prometheus.service') }
end

context 'with alerts configured', alerts: true do
[
{
Expand Down Expand Up @@ -258,13 +283,11 @@
parameters
end

it {
is_expected.to compile
}
it { is_expected.to compile.with_all_deps }
it {
is_expected.to contain_file('prometheus.yaml').with(
'ensure' => 'file',
'path' => '/etc/prometheus/prometheus.yaml',
'path' => configpath,
'owner' => 'root',
'group' => 'prometheus',
'content' => %r{http://domain.tld/path}
Expand All @@ -291,7 +314,7 @@
end

it {
is_expected.not_to contain_file('/etc/prometheus/prometheus.yaml')
is_expected.not_to contain_file(configpath)
}
end
end
Expand Down

0 comments on commit 7a87d62

Please sign in to comment.