From 2d011c8b2815c7677b7253b56a553e7caeb1a384 Mon Sep 17 00:00:00 2001 From: Emilien Macchi Date: Tue, 1 Apr 2014 13:56:06 +0200 Subject: [PATCH] Red Hat: Add crond service support - Add cron service support for both Debian & RH OS families. - Clean unit tests Bug #396 Signed-off-by: Emilien Macchi --- manifests/init.pp | 6 ++++++ spec/classes/cloud_init_spec.rb | 38 ++++++++++++++------------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index d5857b13..1f0a06b2 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -67,7 +67,13 @@ This node is under the control of Puppet ${::puppetversion}. uid => '0', } + $cron_service_name = $::osfamily ? { + 'RedHat' => 'crond', + default => 'cron', + } + service { 'cron': + name => $cron_service_name, ensure => running, enable => true } diff --git a/spec/classes/cloud_init_spec.rb b/spec/classes/cloud_init_spec.rb index d8ee4dbd..5b54bdf5 100644 --- a/spec/classes/cloud_init_spec.rb +++ b/spec/classes/cloud_init_spec.rb @@ -20,6 +20,10 @@ require 'spec_helper' describe 'cloud' do + let :params do + { } + end + shared_examples_for 'private cloud node' do let :pre_condition do @@ -37,26 +41,8 @@ describe 'cloud' do {:ensure => 'file'}.merge(file_defaults) )} - it 'should build motd file with correct message' do - verify_contents(subject, '/etc/motd', - [ - "############################################################################", - "# eNovance IT Operations #", - "############################################################################", - "# #", - "# *** RESTRICTED ACCESS *** #", - "# Only the authorized users may access this system. #", - "# Any attempted unauthorized access or any action affecting the computer #", - "# system of eNovance is punishable under articles 323-1 to 323-7 of #", - "# French criminal law. #", - "# #", - "############################################################################", - "This node is under the control of Puppet ${::puppetversion}." - ] - ) - end - - it { shoud contain_service('cron').with({ + it { should contain_service('cron').with({ + :name => platform_params[:cron_service_name], :ensure => 'running', :enable => true }) } @@ -70,7 +56,11 @@ describe 'cloud' do :puppetversion => '3.3' } end -# it_configures 'private cloud node' + let :platform_params do + { :cron_service_name => 'cron'} + end + + it_configures 'private cloud node' end context 'on RedHat platforms' do @@ -81,11 +71,15 @@ describe 'cloud' do :hostname => 'redhat1' } end + let :platform_params do + { :cron_service_name => 'crond'} + end + let :params do { :rhn_registration => { "username" => "rhn", "password" => "pass" } } end -# it_configures 'private cloud node' + it_configures 'private cloud node' it { should contain_rhn_register('rhn-redhat1') } end