diff --git a/spec/classes/puppet_agent_service_cron_spec.rb b/spec/classes/puppet_agent_service_cron_spec.rb index 17d25f1..a251131 100644 --- a/spec/classes/puppet_agent_service_cron_spec.rb +++ b/spec/classes/puppet_agent_service_cron_spec.rb @@ -1,58 +1,58 @@ require 'spec_helper' describe 'puppet::agent::service::cron' do on_os_under_test.each do |os, facts| context "on #{os}" do if Puppet.version < '4.0' confdir = '/etc/puppet' bindir = '/usr/bin' additional_facts = {} else confdir = '/etc/puppetlabs/puppet' bindir = '/opt/puppetlabs/bin' additional_facts = {:rubysitedir => '/opt/puppetlabs/puppet/lib/ruby/site_ruby/2.1.0'} end if facts[:osfamily] == 'FreeBSD' bindir = '/usr/local/bin' confdir = '/usr/local/etc/puppet' end let :facts do - facts.merge(additional_facts) + facts.merge(additional_facts).merge(:ipaddress => '192.0.2.100') end describe 'when runmode is not cron' do let :pre_condition do "class {'puppet': agent => true}" end if os =~ /\A(windows|archlinux)/ it { should_not contain_cron('puppet') } else it { should contain_cron('puppet').with_ensure('absent') } end end describe 'when runmode => cron' do let :pre_condition do "class {'puppet': agent => true, runmode => 'cron'}" end it do case os when /\A(windows|archlinux)/ should raise_error(Puppet::Error, /Runmode of cron not supported on #{facts[:kernel]} operating systems!/) else should contain_cron('puppet').with({ :command => "#{bindir}/puppet agent --config #{confdir}/puppet.conf --onetime --no-daemonize", :user => 'root', - :minute => ['15','45'], + :minute => ['10','40'], :hour => '*', }) end end end end end end diff --git a/spec/classes/puppet_agent_service_systemd_spec.rb b/spec/classes/puppet_agent_service_systemd_spec.rb index 00cb203..634a4df 100644 --- a/spec/classes/puppet_agent_service_systemd_spec.rb +++ b/spec/classes/puppet_agent_service_systemd_spec.rb @@ -1,107 +1,107 @@ require 'spec_helper' describe 'puppet::agent::service::systemd' do on_os_under_test.each do |os, facts| context "on #{os}" do if Puppet.version < '4.0' confdir = '/etc/puppet' additional_facts = {} else confdir = '/etc/puppetlabs/puppet' additional_facts = {:rubysitedir => '/opt/puppetlabs/puppet/lib/ruby/site_ruby/2.1.0'} end if facts[:osfamily] == 'FreeBSD' confdir = '/usr/local/etc/puppet' elsif facts[:osfamily] == 'Archlinux' confdir = '/etc/puppetlabs/puppet' end let :facts do - facts.merge(additional_facts) + facts.merge(additional_facts).merge(:ipaddress => '192.0.2.100') end describe 'when runmode is not systemd' do let :pre_condition do "class {'puppet': agent => true}" end case os when /\Adebian-8/, /\A(redhat|centos|scientific)-7/, /\Afedora-/, /\Aubuntu-16/, /\Aarchlinux-/ it 'should disable systemd timer' do should contain_class('puppet::agent::service::systemd').with({ 'enabled' => false, }) should contain_service('puppet-run.timer').with({ :provider => 'systemd', :ensure => 'stopped', :name => 'puppet-run.timer', :enable => 'false', }) should contain_file('/etc/systemd/system/puppet-run.timer').with_ensure(:absent) should contain_file('/etc/systemd/system/puppet-run.service').with_ensure(:absent) should contain_exec('systemctl-daemon-reload-puppet').with({ :refreshonly => true, :command => 'systemctl daemon-reload', }) end else it 'should not have a systemd timer service' do should_not contain_service('puppet-run.timer') should_not contain_file('/etc/systemd/system/puppet-run.timer') should_not contain_file('/etc/systemd/system/puppet-run.service') should_not contain_exec('systemctl-daemon-reload-puppet') end end end describe 'when runmode => systemd.timer' do let :pre_condition do "class {'puppet': agent => true, runmode => 'systemd.timer'}" end if Puppet.version < '4.0' bindir = '/usr/bin' elsif facts[:osfamily] == 'FreeBSD' bindir = '/usr/local/bin' elsif facts[:osfamily] == 'Archlinux' bindir = '/usr/bin' else bindir = '/opt/puppetlabs/bin' end case os when /\Adebian-8/, /\A(redhat|centos|scientific)-7/, /\Afedora-/, /\Aubuntu-16/, /\Aarchlinux-/ it 'should enable systemd timer' do should contain_class('puppet::agent::service::systemd').with({ 'enabled' => true, }) should contain_file('/etc/systemd/system/puppet-run.timer'). - with_content(/.*OnCalendar\=\*-\*-\* \*\:15,45:00.*/) + with_content(/.*OnCalendar\=\*-\*-\* \*\:10,40:00.*/) should contain_file('/etc/systemd/system/puppet-run.service'). with_content(/.*ExecStart=#{bindir}\/puppet agent --config #{confdir}\/puppet.conf --onetime --no-daemonize.*/) should contain_exec('systemctl-daemon-reload-puppet').with({ :refreshonly => true, :command => 'systemctl daemon-reload', }) should contain_service('puppet-run.timer').with({ :provider => 'systemd', :ensure => 'running', :name => 'puppet-run.timer', :enable => 'true', }) end else it { should raise_error(Puppet::Error, /Runmode of systemd.timer not supported on #{facts[:kernel]} operating systems!/) } end end end end end