Skip to content

Commit

Permalink
Add service support (fixes #36 and #39)
Browse files Browse the repository at this point in the history
  • Loading branch information
torrancew committed Apr 28, 2016
1 parent 5a2443a commit 1eeb381
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 1 deletion.
1 change: 1 addition & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
$package_ensure = 'installed'
) {
class { '::cron::install': package_ensure => $package_ensure }
-> class { 'cron::service': }
}

26 changes: 26 additions & 0 deletions manifests/service.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Class: cron::service
#
# This class ensures that the distro-appropriate cron service is running
#
# Actions:
#
# Requires:
#
# Sample Usage:
# This class should not be used directly under normal circumstances
# Instead, use the *cron* class.

class cron::service {
$service_name = $::operatingsystem ? {
/(RedHat|CentOS|Amazon|OracleLinux)/ => 'crond',
default => 'cron',
}

service {
'crond':
ensure => 'running',
enable => true,
name => $service_name,
}
}

7 changes: 6 additions & 1 deletion spec/classes/cron_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
require 'spec_helper'

describe 'cron' do
it { should contain_class( 'cron::install' ) }
it {
should contain_class( 'cron::install' ).with({
'before' => ['Class[Cron::Service]'],
})
should contain_class( 'cron::service' )
}
end

8 changes: 8 additions & 0 deletions spec/classes/service_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require 'spec_helper'

describe 'cron::service' do
it do
should contain_service( 'crond' ).with( 'ensure' => 'running' )
end
end

0 comments on commit 1eeb381

Please sign in to comment.