aboutsummaryrefslogtreecommitdiffstats
path: root/modules/buildsystem/manifests/init.pp
blob: 6b6d8eb1b56ec5374cda4c149dcfcb319e6ff74a (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
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
class buildsystem {

    class base {
	$build_login = "iurt"
	$build_home_dir = "/home/$build_login"
	$sched_login = "schedbot"
	$sched_home_dir = "/var/lib/$sched_login"
	$packages_archivedir = "$sched_home_dir/old"
	$repository_root = "/distrib/bootstrap"
	$mirror_root = "/distrib/mirror"
	$packagers_group = 'mga-packagers'
	$packagers_committers_group = 'mga-packagers-committers'
	$createsrpm_path = '/usr/share/mgarepo/create-srpm'

	include ssh::auth
	ssh::auth::key { $build_login: # declare a key for build bot: RSA, 2048 bits
		home => $build_home_dir,
	}
	ssh::auth::key { $sched_login: # declare a key for sched bot: RSA, 2048 bits
		home => $sched_home_dir,
	}
    }

    class mainnode inherits base {
        include iurtuser

        sshuser { $sched_login:
          homedir => $sched_home_dir,
          comment => "System user used to schedule builds",
        }

        ssh::auth::client { $sched_login: }

        ssh::auth::server { [$sched_login, $build_login]: }

        # FIXME Add again task-bs-cluster-main when it will require mgarepo instead of repsys
        $package_list = ['iurt']
        package { $package_list: }

        apache::vhost_other_app { "repository.$domain":
            vhost_file => "buildsystem/vhost_repository.conf",
        }

        $location = "/var/www/bs"
        file { ["$location","$location/data"]:
            ensure => directory,
        }

        apache::vhost_base { "pkgsubmit.$domain":
            aliases => { "/uploads" => "$sched_home_dir/uploads" },
            location => $location,
	    content => template("buildsystem/vhost_pkgsubmit.conf"),
        }

        subversion::snapshot { $location:
            source => "svn://svn.$domain/soft/buildsystem/web/",
        }

        define media_cfg() {
            $arch = $name
            file { "$repository_root/distrib/cauldron/$arch/media/media_info/media.cfg":
	            owner => $sched_login,
	            group => $sched_login,
	            source => "puppet:///modules/buildsystem/$arch/media.cfg",
	        }
        }

        media_cfg { ["i586","x86_64"]: }

        include scheduler
        include gatherer
        include buildsystem::mgarepo
        include buildsystem::signbot
        include youri_submit
        include buildsystem::check_missing_deps

        cron { "dispatch jobs":
            user => $sched_login,
            command => "emi ; ulri",
            minute => "*",
        }
    }

    class buildnode inherits base {
        include iurt
    }

    class scheduler {
        # ulri        
        include iurtupload
    }

    class gatherer {
        # emi
        include iurtupload
    }

    class iurtupload {
        file { "/etc/iurt/upload.conf":
            owner => $build_login,
            group => $build_login,
            require => File["/etc/iurt"],
            content => template("buildsystem/upload.conf")
        }
    }

    class binrepo inherits base {
        include sudo
        $binrepo_login = "binrepo"
	$binrepo_homedir = "/var/lib/$binrepo_login"
        $binrepodir = "$binrepo_homedir/data"
	$uploadinfosdir = "$binrepo_homedir/infos"
	$uploadbinpath = '/usr/local/bin/upload-bin'
	$uploadbinpathwrapper = '/usr/local/bin/wrapper.upload-bin'
	$uploadmail_from = "root@$domain"
	$uploadmail_to = "packages-commits@ml.$domain"

	user {"$binrepo_login":
	    ensure => present,
	    comment => "Binary files repository",
	    managehome => true,
	    shell => "/bin/bash",
	    home => "$binrepo_homedir",
	}

        file { [$binrepodir, $uploadinfosdir]:
            ensure => directory,
            owner => $binrepo_login,
        }

        local_script { "upload-bin":
            content => template('buildsystem/upload-bin'),
        }

        local_script { "wrapper.upload-bin":
            content => template('buildsystem/wrapper.upload-bin'),
        }

	sudo::sudoers_config { "binrepo":
	    content => template("buildsystem/sudoers.binrepo")
	}

	apache::vhost_base { "binrepo.$domain":
	    location => $binrepodir,
	    content => template("buildsystem/vhost_binrepo.conf"),
	}
    }
    
    class youri_submit {
        include sudo

        local_script {
            "mga-youri-submit": content => template("buildsystem/mga-youri-submit");
            "mga-youri-submit.wrapper": content => template("buildsystem/mga-youri-submit.wrapper");
            "submit_package": content => template('buildsystem/submit_package.pl');
        }

        sudo::sudoers_config { "mga-youri-submit":
            content => template("buildsystem/sudoers.youri")
        }

        package { "rpmlint": }

        file { "/etc/rpmlint/config":
            require => Package['rpmlint'],
            content => template("buildsystem/rpmlint.conf")
        }

        # directory that hold configuration auto extracted after upload
        # of the rpmlint policy
        file { "/etc/rpmlint/extracted.d/":
            ensure => directory,
            require => Package['rpmlint'],
            owner => $sched_login,
        }

        # ordering is automatic :
        # http://docs.puppetlabs.com/learning/ordering.html#autorequire
        file { "/etc/youri":
            ensure => "directory",
        }

        file {
            "/etc/youri/submit-todo.conf": content => template("buildsystem/submit-todo.conf");
            "/etc/youri/submit-upload.conf": content => template("buildsystem/submit-upload.conf");
            "/etc/youri/acl.conf": content => template("buildsystem/youri_acl.conf");
        }

        # FIXME use the correct perl directory
        file { "/usr/lib/perl5/site_perl/5.10.1/Youri/Repository":
            ensure => "directory",
        }

        file { '/usr/lib/perl5/site_perl/5.10.1/Youri/Repository/Mageia.pm':
            source => "puppet:///modules/buildsystem/Mageia.pm",
        }

        $package_list = ['perl-SVN', 'mdv-distrib-tools', 'perl-Youri-Media',
                         'perl-Youri-Package', 'perl-Youri-Repository',
                         'perl-Youri-Utils', 'perl-Youri-Config', 'mga-youri-submit']

        package { $package_list: }
    }

    # $groups: array of secondary groups (only local groups, no ldap)
    define sshuser($homedir, $comment, $groups = []) {
        group {"$title": 
            ensure => present,
        }

        user {"$title":
            ensure => present,
            comment => $comment,
            managehome => true,
	    home => $homedir,
            gid => $title,
	    groups => $groups,
            shell => "/bin/bash",
            notify => Exec["unlock$title"],
            require => Group[$title],
        }

        # set password to * to unlock the account but forbid login through login
        exec { "unlock$title":
            command => "usermod -p '*' $title",
            refreshonly => true,
        }

        file { $homedir:
            ensure => "directory",
            owner  => $title,
            group  => $title,
            require => User[$title],
        }

        file { "$homedir/.ssh":
            ensure => "directory",
            mode   => 600,
            owner  => $title,
            group  => $title,
            require => File[$homedir],
        }
    }

    class iurtuser {
        sshuser { $build_login:
          homedir => $build_home_dir,
          comment => "System user used to run build bots",
        }

        file { "/etc/iurt":
            ensure => "directory",
        }
    }

    class iurt {
        include sudo
        include iurtuser
        ssh::auth::client { $build_login: }
        ssh::auth::server { $sched_login: user => $build_login }

        $tidy_age = "8w"
        # remove old build directory
        tidy { "$build_home_dir/iurt":
            age => $tidy_age,
            recurse => true,
            matches => ['[0-9][0-9].*\..*\..*\.[0-9]*',"log","*.rpm","*.log","*.mga[0-9]+"],
            rmdirs => true,
        }

        # build node common settings
        # we could have the following skip list to use less space:
        # '/(drakx-installer-binaries|drakx-installer-advertising|gfxboot|drakx-installer-stage2|mandriva-theme)/'
        $package_list = ['task-bs-cluster-chroot', 'iurt']
        package { $package_list: }

        file { "/etc/iurt/build":
            ensure => "directory",
        }

        define iurt_config() {

            $distribution = $name
            file { "/etc/iurt/build/$distribution.conf":
                owner => $build_login,
                group => $build_login,
                content => template("buildsystem/iurt.$distribution.conf")
            }
        }

        iurt_config { ["1","cauldron","mandriva2010.1"]: }

       	sudo::sudoers_config { "iurt":
            content => template("buildsystem/sudoers.iurt")
        }
    }

    # A script to copy on valstar the 2010.1 rpms built on jonund
    class sync20101 inherits base {
        local_script { "sync2010.1":
	        content => template("buildsystem/sync2010.1"),
        }
    }

    # a script to build 2010.1 packages. used on jonund
    class iurt20101 inherits base {
        local_script { "iurt2010.1":
	        content => template("buildsystem/iurt2010.1"),
        }
    }
}