summaryrefslogtreecommitdiff
path: root/manifests/cron/base.pp
blob: 42222d66b554ba99b27a017d103f6fe460f7a1fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# manifests/cron/base.pp
class puppet::cron::base inherits puppet::base {

  case $::operatingsystem {
    debian: { if $::lsbdistcodename != 'lenny' { $stop_service = true } else { $stop_service = false }  }
    openbsd, ubuntu: { $stop_service = false }
    default: { $stop_service = true }
  }

  if !$puppet::cron::cron_time {
    $crontime_interval_minute = fqdn_rand(29)
    $crontime_interval_minute2 = inline_template("<%= 30+scope.lookupvar('puppet::cron::cron_time').to_i %>")
    $crontime = "${crontime_interval_minute},${crontime_interval_minute2} * * * *"
  } else {
    $crontime = $puppet::cron::cron_time
  }

  if $puppet::http_compression {
     $http_compression_str = '--http_compression'
  } else {
    $http_compression_str = ''
  }

  Service['puppet']{
    enable => false,
  }

  if $stop_service == true {
    $puppet_majorversion = regsubst($::puppetversion,'^(\d+\.\d+).*$','\1')
    if $puppet_majorversion == '2.6' {
      Service['puppet']{
        ensure => stopped,
      }
    } else {
      Service['puppet']{
        hasstatus => false,
        pattern => 'puppetd',
      }
      # this works only on < 2.6
      exec { 'stop_puppet':
        command => 'kill `cat /var/run/puppet/puppetd.pid`',
        onlyif => 'test -f /var/run/puppet/puppetd.pid',
        require => Service['puppet'],
      }
    }
  }
}