|
239 | 239 | end |
240 | 240 | end |
241 | 241 |
|
| 242 | + describe 'when runmode => cron with specified time' do |
| 243 | + let :params do |
| 244 | + super().merge(runmode: 'cron', |
| 245 | + run_hour: 22, |
| 246 | + run_minute: 01 |
| 247 | + ) |
| 248 | + end |
| 249 | + |
| 250 | + case os |
| 251 | + when /\A(windows|archlinux)/ |
| 252 | + it { is_expected.to raise_error(Puppet::Error, /Runmode of cron not supported on #{facts[:kernel]} operating systems!/) } |
| 253 | + when /\Adebian-/, /\A(redhat|centos|scientific)-7/, /\Afedora-/, /\Aubuntu-(16|18)/ |
| 254 | + it { is_expected.to contain_class('puppet::agent::service::cron').with_enabled(true) } |
| 255 | + it { is_expected.to contain_class('puppet::agent::service::daemon').with_enabled(false) } |
| 256 | + it do |
| 257 | + is_expected.to contain_service('puppet') |
| 258 | + .with_ensure('stopped') |
| 259 | + .with_name('puppet') |
| 260 | + .with_hasstatus('true') |
| 261 | + .with_enable('false') |
| 262 | + end |
| 263 | + it { is_expected.to contain_class('puppet::agent::service::systemd').with_enabled(false) } |
| 264 | + it { is_expected.to contain_service('puppet-run.timer').with_ensure(:stopped) } |
| 265 | + it do |
| 266 | + is_expected.to contain_cron('puppet') |
| 267 | + .with_command("#{bindir}/puppet agent --config #{confdir}/puppet.conf --onetime --no-daemonize") |
| 268 | + .with_user('root') |
| 269 | + .with_minute('1') |
| 270 | + .with_hour('22') |
| 271 | + end |
| 272 | + else |
| 273 | + it { is_expected.to compile.with_all_deps } |
| 274 | + it { is_expected.to contain_class('puppet::agent::service::cron').with_enabled(true) } |
| 275 | + it { is_expected.to contain_class('puppet::agent::service::daemon').with_enabled(false) } |
| 276 | + it { is_expected.to contain_class('puppet::agent::service::systemd').with_enabled(false) } |
| 277 | + it { is_expected.not_to contain_service('puppet-run.timer') } |
| 278 | + it do |
| 279 | + is_expected.to contain_cron('puppet') |
| 280 | + .with_command("#{bindir}/puppet agent --config #{confdir}/puppet.conf --onetime --no-daemonize") |
| 281 | + .with_user('root') |
| 282 | + .with_minute('1') |
| 283 | + .with_hour('22') |
| 284 | + end |
| 285 | + end |
| 286 | + end |
| 287 | + |
242 | 288 | describe 'when runmode => systemd.timer' do |
243 | 289 | let :params do |
244 | 290 | super().merge(runmode: 'systemd.timer') |
|
285 | 331 | end |
286 | 332 | end |
287 | 333 |
|
| 334 | + describe 'when runmode => systemd.timer with configured time' do |
| 335 | + let :params do |
| 336 | + super().merge(runmode: 'systemd.timer', |
| 337 | + run_hour: 22, |
| 338 | + run_minute: 01 |
| 339 | + ) |
| 340 | + end |
| 341 | + |
| 342 | + case os |
| 343 | + when /\Adebian-/, /\A(redhat|centos|scientific)-7/, /\Afedora-/, /\Aubuntu-(16|18)/, /\Aarchlinux-/ |
| 344 | + it { is_expected.to compile.with_all_deps } |
| 345 | + it { is_expected.to contain_class('puppet::agent::service::daemon').with_enabled(false) } |
| 346 | + it { is_expected.to contain_class('puppet::agent::service::cron').with_enabled(false) } |
| 347 | + it { is_expected.to contain_class('puppet::agent::service::systemd').with_enabled(true) } |
| 348 | + it { is_expected.to contain_service('puppet-run.timer').with_ensure(:running) } |
| 349 | + |
| 350 | + it do |
| 351 | + is_expected.to contain_file('/etc/systemd/system/puppet-run.timer') |
| 352 | + .with_content(/.*OnCalendar\=\*-\*-\* 22:1:00.*/) |
| 353 | + end |
| 354 | + |
| 355 | + it do |
| 356 | + is_expected.to contain_file('/etc/systemd/system/puppet-run.timer') |
| 357 | + .with_content(/^RandomizedDelaySec\=0$/) |
| 358 | + end |
| 359 | + |
| 360 | + it do |
| 361 | + is_expected.to contain_file('/etc/systemd/system/puppet-run.service') |
| 362 | + .with_content(%r{^ExecStart=#{bindir}/puppet agent --config #{confdir}/puppet.conf --onetime --no-daemonize --detailed-exitcode --no-usecacheonfailure$}) |
| 363 | + end |
| 364 | + |
| 365 | + it do |
| 366 | + is_expected.to contain_exec('systemctl-daemon-reload-puppet') |
| 367 | + .with_refreshonly(true) |
| 368 | + .with_command('systemctl daemon-reload') |
| 369 | + end |
| 370 | + |
| 371 | + it do |
| 372 | + is_expected.to contain_service('puppet-run.timer') |
| 373 | + .with_provider('systemd') |
| 374 | + .with_ensure('running') |
| 375 | + .with_name('puppet-run.timer') |
| 376 | + .with_enable('true') |
| 377 | + end |
| 378 | + else |
| 379 | + it { is_expected.to raise_error(Puppet::Error, /Runmode of systemd.timer not supported on #{facts[:kernel]} operating systems!/) } |
| 380 | + end |
| 381 | + end |
| 382 | + |
288 | 383 | describe 'when runmode => none' do |
289 | 384 | let :params do |
290 | 385 | super().merge(runmode: 'none') |
|
0 commit comments