Skip to content

Commit

Permalink
Merge pull request voxpupuli#90 from bastelfreak/systemd
Browse files Browse the repository at this point in the history
manage systemd unit files with camptocamp/systemd
  • Loading branch information
wyardley authored Oct 24, 2017
2 parents aada608 + eaaf704 commit c685bbd
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 41 deletions.
1 change: 1 addition & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ fixtures:
repositories:
archive: "https://github.com/voxpupuli/puppet-archive"
stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib"
systemd: "https://github.com/camptocamp/puppet-systemd"
symlinks:
"prometheus": "#{source_dir}"
13 changes: 2 additions & 11 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,10 @@
}
}
'systemd' : {
file { '/etc/systemd/system/prometheus.service':
mode => '0644',
owner => 'root',
group => 'root',
notify => $systemd_notify,
include 'systemd'
::systemd::unit_file {'prometheus.service':
content => template('prometheus/prometheus.systemd.erb'),
}
exec { 'prometheus-systemd-reload':
command => 'systemctl daemon-reload',
path => [ '/usr/bin', '/bin', '/usr/sbin' ],
refreshonly => true,
}

}
'sysv' : {
file { '/etc/init.d/prometheus':
Expand Down
12 changes: 2 additions & 10 deletions manifests/daemon.pp
Original file line number Diff line number Diff line change
Expand Up @@ -168,18 +168,10 @@
}
}
'systemd' : {
file { "/etc/systemd/system/${name}.service":
mode => '0644',
owner => 'root',
group => 'root',
include 'systemd'
::systemd::unit_file {"${name}.service":
content => template('prometheus/daemon.systemd.erb'),
}
~> exec { "${name}-systemd-reload":
command => 'systemctl daemon-reload',
path => [ '/usr/bin', '/bin', '/usr/sbin' ],
refreshonly => true,
notify => $notify_service,
}
}
'sysv' : {
file { "/etc/init.d/${name}":
Expand Down
4 changes: 4 additions & 0 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
{
"name": "puppetlabs/stdlib",
"version_requirement": ">= 4.6.0 <5.0.0"
},
{
"name": "camptocamp/systemd",
"version_requirement": ">= 1.0.0 < 2.0.0"
}
],
"operatingsystem_support": [
Expand Down
12 changes: 9 additions & 3 deletions spec/classes/blackbox_exporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,16 @@
}
end

describe 'install correct binary' do
describe 'with all defaults' do
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_file('/usr/local/bin/blackbox_exporter').with('target' => '/opt/blackbox_exporter-0.6.0.linux-amd64/blackbox_exporter') }
end
describe 'config file contents' do
it { is_expected.to contain_prometheus__daemon('blackbox_exporter') }
it { is_expected.to contain_user('blackbox-exporter') }
it { is_expected.to contain_group('blackbox-exporter') }
it { is_expected.to contain_service('blackbox_exporter') }
it { is_expected.to contain_archive('/tmp/blackbox_exporter-0.6.0.tar.gz') }
it { is_expected.to contain_file('/opt/blackbox_exporter-0.6.0.linux-amd64/blackbox_exporter') }
it { is_expected.to contain_class('prometheus::params') }
it {
is_expected.to contain_file('/etc/blackbox-exporter.yaml')
verify_contents(catalogue, '/etc/blackbox-exporter.yaml', ['---', 'modules:', ' http_2xx:', ' prober: http'])
Expand Down
18 changes: 1 addition & 17 deletions spec/classes/prometheus_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,23 +112,7 @@
}
elsif ['centos-7-x86_64', 'debian-8-x86_64', 'redhat-7-x86_64', 'ubuntu-16.04-x86_64'].include?(os)
# init_style = 'systemd'

it {
is_expected.to contain_file('/etc/systemd/system/prometheus.service').with(
'mode' => '0644',
'owner' => 'root',
'group' => 'root',
'content' => File.read(fixtures('files', 'prometheus.systemd'))
).that_notifies(['Exec[prometheus-systemd-reload]', 'Class[Prometheus::Run_service]'])
}

it {
is_expected.to contain_exec('prometheus-systemd-reload').with(
'command' => 'systemctl daemon-reload',
'path' => ['/usr/bin', '/bin', '/usr/sbin'],
'refreshonly' => true
)
}
it { is_expected.to contain_systemd__unit_file('prometheus.service') }
elsif ['ubuntu-14.04-x86_64'].include?(os)
# init_style = 'upstart'

Expand Down

0 comments on commit c685bbd

Please sign in to comment.