summaryrefslogtreecommitdiff
path: root/manifests/daemon.pp
blob: 61475a40d510bad2366695e616921e9147960b16 (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# manage puppet service
class puppet::daemon(
  $master        = false,
  $ensure        = hiera('puppet::daemon::ensure',       ''),
  $port          = hiera('puppet::daemon::port',         "8140"),
  $runinterval   = hiera('puppet::daemon::runinterval',  "7200"),
  $configtimeout = hiera('puppet::daemon::configtimeout', "120"),
  $server        = hiera('puppet::daemon::server',        "puppet.${::domain}")
) {
  class { "puppet::base":
    start_on_boot => true
  }

  include cron

  service { "puppet":
    enable     => true,
    ensure     => running,
    hasrestart => true,
    require    => [ Package["puppet"], File["/etc/default/puppet"] ],
  }

  # Name of puppet agent section in config file
  if $::puppetversion <= "0.25.4" {
    $agent_name = 'puppetd'
  } else {
    $agent_name = 'agent'
  }

  # Puppet config file
  file { "/etc/puppet/puppet.conf":
    ensure  => file,
    owner   => puppet,
    group   => puppet,
    content => $master ? {
      true    => undef, # the content is in the git repo
      default => template("puppet/puppet-node.conf.erb"),
    }
  }

  # Cron rule to restart puppet minutes after puppetmaster is restarted
  cron { "puppet-restart":
    command  => "/etc/init.d/puppet restart > /dev/null 2>&1",
    user     => root,
    hour     => "*/1",
    minute   => "10",
    ensure   => absent,
    require  => Service["puppet"],
  }

  file { "/usr/local/sbin/check-puppetd.sh":
    content => template("puppet/check-puppetd.sh.erb"),
    owner   => "puppet",
    group   => "puppet",
    mode    => 0755,
    ensure  => present,
  }

  cron { "puppetd-check":
    command  => "/usr/local/sbin/check-puppetd.sh > /dev/null",
    user     => root,
    hour     => "*/1",
    minute   => "0",
    require  => File["/usr/local/sbin/check-puppetd.sh"],
    ensure   => present,
  }

  # Thanks to https://labs.riseup.net/code/projects/shared-puppet
  file { "/etc/cron.d/puppetd":
    source => "puppet:///modules/puppet/cron.d/puppetd",
    owner  => root,
    group  => root,
    mode   => 0644;
  }

  # Restore to original state after the following bug is addressed:
  # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=625626
  if $::lsbdistcodename == 'squeeze' {
    file { "/etc/logrotate.d/puppetmaster":
      ensure => absent,
    }
  }
}