public
Description: Public Puppet Configuration by The SANS Institute
Homepage:
Clone URL: git://github.com/jtimberman/puppet.git
Joshua Timberman (author)
Wed Jun 18 08:46:57 -0700 2008
puppet / dirvish / manifests / init.pp
100644 163 lines (138 sloc) 5.076 kb
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# class name_of_class { }
# define definition { }
#
# Classes and Definitions here.
 
class dirvish {
 
    class client {
        # client portion is limited to installing an SSH key on the box
        # for the dirvish server to use to connect to it.
        # Since this is site specific, this is doen via our local module
    }
 
    class server {
 
        package {
            ["perl-Time-modules",
            "perl-Time-Period"]:
            ensure => installed,
            require => Yumrepo["rpmforge"],
        }
 
        file { "/etc/dirvish":
            ensure => directory,
            owner => "root",
            group => "root",
            mode => "0755",
        }
 
        file {
            "/usr/sbin/dirvish" :
                owner => "root", group => "root", mode => "0755",
                source => "puppet:///dirvish/bin/dirvish";
            "/usr/sbin/dirvish-expire" :
                owner => "root", group => "root", mode => "0755",
                source => "puppet:///dirvish/bin/dirvish-expire";
            "/usr/sbin/dirvish-locate" :
                owner => "root", group => "root", mode => "0755",
                source => "puppet:///dirvish/bin/dirvish-locate";
            "/usr/sbin/dirvish-runall" :
                owner => "root", group => "root", mode => "0755",
                source => "puppet:///dirvish/bin/dirvish-runall";
        }
 
        file {
            "/usr/share/man/man5/dirvish.conf.5" :
                owner => "root", group => "root", mode => "0644",
                source => "puppet:///dirvish/man/dirvish.conf.5";
            "/usr/share/man/man8/dirvish.8" :
                owner => "root", group => "root", mode => "0644",
                source => "puppet:///dirvish/man/dirvish.8";
            "/usr/share/man/man8/dirvish-expire.8" :
                owner => "root", group => "root", mode => "0644",
                source => "puppet:///dirvish/man/dirvish-expire.8";
            "/usr/share/man/man8/dirvish-locate.8" :
                owner => "root", group => "root", mode => "0644",
                source => "puppet:///dirvish/man/dirvish-locate.8";
            "/usr/share/man/man8/dirvish-runall.8" :
                owner => "root", group => "root", mode => "0644",
                source => "puppet:///dirvish/man/dirvish-runall.8",
        }
    }
}
 
define dirvish::config ($banks, $imagedef = "%Y%m%d", $index = "none", $log = "none",
        $excludes = [''], $runall = [''], $time = false, $expiredef = "+2 weeks", $expires = ['']) {
 
    file { "/etc/dirvish/master.conf":
        owner => "root",
        group => "root",
        mode => "0640",
        content => template("dirvish/master.conf.erb")
    }
}
 
define dirvish::bank ($bank) {
    file { "$bank":
        ensure => directory,
        owner => "root",
        group => "root",
        mode => "0750",
    }
}
 
define dirvish::vault ($bank, $vault) {
    file { "$bank/$vault":
        ensure => directory,
        owner => "root",
        group => "root",
        mode => "0750",
    }
    file { "$bank/$vault/dirvish":
        ensure => directory,
        owner => "root",
        group => "root",
        mode => "0750",
        require => File["$bank/$vault"],
    }
}
 
define dirvish::branch ($bank, $vault, $host, $fs,
            $xdev = "true", $index = "gzip", $excludes = [''], $parent = false) {
 
    file { "$bank/$vault/dirvish/$name.conf":
        owner => "root",
        group => "root",
        mode => "0640",
        content => template("dirvish/branch.conf.erb")
    }
 
    $cmd = $parent ? {
        false => "dirvish --init --branch $vault:$name",
        default => "dirvish --reference $parent --branch $vault:$name",
    }
 
    exec { "branch-create-$name":
        command => $cmd,
        creates => "$bank/$vault/dirvish/$name.hist",
        require => [File["/usr/sbin/dirvish"], File["$bank/$vault/dirvish/$name.conf"]]
    }
}
 
define dirvish::stats ($email, $period = "yesterday") {
 
    file { "/usr/sbin/$name":
        owner => "root",
        group => "root",
        mode => "0755",
        content => template("dirvish/dirvish-stats.erb")
    }
}
 
define dirvish::userkey ($user = "root", $group = "root", $key = false, $file = "authorized_keys2") {
 
    $dir = $user ? {
        "root" => "/root/.ssh",
        default => "/home/$user/.ssh",
    }
 
    exec { "dirvish-create-keydir":
        command => "/bin/mkdir -m 0700 -p $dir",
        creates => "$dir",
    }
    exec { "dirvish-modify-keydir":
        command => "/bin/chown $user:$group $dir",
        unless => "stat --printf='%U:%G\n' $dir | grep '$user:$group' 1>/dev/null",
        require => Exec["dirvish-create-keydir"]
    }
 
    line { "dirvish-pub-key":
        ensure => present,
        file => "$dir/$file",
        line => "$key",
        require => Exec["dirvish-modify-keydir"]
    }
 
}
 
 
# vim modeline - have 'set modeline' and 'syntax on' in your ~/.vimrc.
# vi:syntax=puppet:filetype=puppet:ts=4:et:
# EOF