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

manage systemd unit files with camptocamp/systemd #90

Merged
merged 1 commit into from
Oct 24, 2017
Merged
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
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