summaryrefslogtreecommitdiff
path: root/manifests/puppetmasterd.pp
blob: 2b7ace5018a93fbab309469ed97df9d7cbbe0e82 (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
# handles puppetmasterd service
class puppetmasterd {
  # warns that this node has a puppetmaster
  $puppetmasterd_present = true

  # then include puppet class
  include puppetd

  # needed packages
  package {
    "puppetmaster":  ensure => installed;
    "sqlite3":       ensure => installed;
    "libmysql-ruby": ensure => installed;
  }

  # for storeconfigs
  include mysql::server

  service { "puppetmaster":
    enable     => true,
    ensure     => running,
    hasrestart => true,
  }

  # cron rule to update puppet config repository every 5 minutes
  cron { "puppet-update":
    command  => "/usr/local/sbin/update-puppet-conf.sh &> /dev/null",
    user     => puppet,
    minute   => "*/5",
    ensure   => present,
    require  => [ File["/usr/local/sbin/update-puppet-conf.sh"], User["puppet"] ],
  }

  # cron rule to restart puppetmaster before restarting the nodes
  cron { "puppetmaster-restart":
    command  => "/etc/init.d/puppetmaster restart &> /dev/null",
    user     => root,
    hour     => "*/1",
    minute   => "0",
    ensure   => absent,
  }

  # and the script to the cron-job above
  file { "/usr/local/sbin/update-puppet-conf.sh":
    source => "puppet://$server/modules/puppet/update-puppet-conf.sh",
    owner  => "puppet",
    group  => "puppet",
    mode   => 0755,
    ensure => present,
  }

  # TODO: database creation as suggested by
  # http://reductivelabs.com/trac/puppet/wiki/Recipes/MySQLStoredConfiguration
  #exec { "create-storeconfigs-db":
  #    command         => "/usr/bin/mysqladmin create puppet",
  #    unless          => "/usr/bin/mysqlcheck -s puppet",
  #    notify          => Exec["create-storeconfigs-user"],
  #}
  #exec { "create-storeconfigs-user":
  #    command         => "/usr/bin/mysql -e 'grant all privileges on puppet.* to puppet@localhost identified by \"puppet\"'",
  #    refreshonly     => true,
  #}

}