summaryrefslogtreecommitdiff
path: root/manifests/puppetmaster.pp
blob: 7e80792c060f68c961f6cb5f5d9f8a393ba5a753 (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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# manifests/puppetmaster.pp

import "storeconfigs.pp"

class puppet::puppetmaster inherits puppet {
    case $operatingsystem {
        debian: { include puppet::puppetmaster::package }
        centos: { include puppet::puppetmaster::centos }
        default: {
            case $kernel {
                linux: { include puppet::puppetmaster::linux }
            }
        }
    }
    include puppet::puppetmaster::base
}

class puppet::puppetmaster::base inherits puppet::base {

    File[puppet_config]{
        source => [ "puppet://$server/files/puppet/master/puppet.conf",
                    "puppet://$server/puppet/master/puppet.conf" ],
        notify => [Service[puppet],Service[puppetmaster] ],
    }

    $real_puppet_fileserverconfig = $puppet_fileserverconfig ? {
        '' => "/etc/puppet/fileserver.conf",
        default => $puppet_fileserverconfig,
    }

    file { "$real_puppet_fileserverconfig":
        source => [ "puppet://$server/files/puppet/master/${fqdn}/fileserver.conf",
                    "puppet://$server/files/puppet/master/fileserver.conf",
                    "puppet://$server/puppet/master/fileserver.conf" ],
        notify => [Service[puppet],Service[puppetmaster] ],
        owner => root, group => 0, mode => 600;
    }

    if $puppetmaster_storeconfigs {
        include puppet::puppetmaster::storeconfigs
    }

    # restart the master from time to time to avoid memory problems
    file{'/etc/cron.d/puppetmaster.cron':
        source => [ "puppet://$server/puppet/cron.d/puppetmaster.${operatingsystem}",
                    "puppet://$server/puppet/cron.d/puppetmaster" ],
        owner => root, group => 0, mode => 0644;
    }
}


define puppet::puppetmaster::hasdb(
    $dbtype = 'mysql',
    $dbname = 'puppet',
    $dbhost = 'localhost',
    # this is needed due to the collection of the databases
    $dbhostfqdn = "${fqdn}",
    $dbuser = 'puppet',
    $dbpwd = $puppet_storeconfig_password,
    $dbconnectinghost = 'locahost'
){

    case $puppet_storeconfig_password {
        '': { fail("No \$puppet_storeconfig_password is set, please set it in your manifests or site.pp to add a password") }
    }

    case $dbtype {
        'mysql': {  puppet::puppetmaster::hasdb::mysql{$name: dbname => $dbname, dbhost => $dbhost, dbuser => $dbuser, dbpwd => $dbpwd, } }
    }
}

# don't use this define use the general interface
define puppet::puppetmaster::hasdb::mysql(
    $dbname = 'puppet',
    $dbhost = 'localhost',
    $dbhostfqdn = "${fqdn}",
    $dbuser = 'puppet',
    $dbpwd,
    $dbconnectinghost = 'localhost'
){
    @@mysql_database{$dbname: 
        tag => "mysql_${dbhostfqdn}",
    }

    @@mysql_user{"${dbuser}@${dbconnectinghost}":
        password_hash => mysql_password("$dbpwd"),
        require => Mysql_database[$dbname],    
        tag => "mysql_${dbhostfqdn}",
    }


    @@mysql_grant{"${dbuser}@${dbconnectinghost}/${dbname}":
        privileges => all,
        require => Mysql_user["${dbuser}@${dbconnectinghost}"],
        tag => "mysql_${dbhostfqdn}",
    }

    munin::plugin::deploy{'puppetresources':
        source => "puppet/munin/puppetresources.mysql",
        config => "env.mysqlopts --user=$dbuser --password=$dbpwd -h $dbhost\nenv.puppetdb $dbname",
    }
}