a8affb0ceab95248fc66e523a145596927bbf8cb
[mirror/dsa-puppet.git] / modules / buildd / manifests / init.pp
1 class buildd ($ensure=present) {
2         # Do nothing until we get the buildd user from ldap
3         if $::buildd_user_exists {
4                 #
5                 # home directory
6                 #
7                 file { '/home/buildd':
8                         ensure  => directory,
9                         mode    => '2755',
10                         group   => buildd,
11                         owner   => buildd,
12                 }
13
14
15                 #
16                 # sbuild configuration, including chroots
17                 #
18                 include schroot
19
20                 package { 'sbuild':
21                         ensure => installed,
22                         tag    => extra_repo,
23                 }
24                 package { 'libsbuild-perl':
25                         ensure => installed,
26                         tag    => extra_repo,
27                         before => Package['sbuild']
28                 }
29                 file { '/etc/sbuild/sbuild.conf':
30                         source  => 'puppet:///modules/buildd/sbuild.conf',
31                         require => Package['sbuild'],
32                 }
33                 if $has_srv_buildd {
34                         concat::fragment { 'dsa-puppet-stuff--buildd-update-schroots':
35                                 target => '/etc/cron.d/dsa-puppet-stuff',
36                                 content  => @(EOF)
37                                         13 22 * * 0,3 root PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin setup-all-dchroots buildd
38                                         | EOF
39                         }
40                 }
41                 exec { 'add-buildd-user-to-sbuild':
42                         command => 'adduser buildd sbuild',
43                         onlyif  => "getent group sbuild > /dev/null && ! getent group sbuild | grep '\\<buildd\\>' > /dev/null"
44                 }
45
46
47                 #
48                 # dupload configuration
49                 #
50                 package { 'dupload':
51                         ensure => installed,
52                 }
53                 file { '/etc/dupload.conf':
54                         source  => 'puppet:///modules/buildd/dupload.conf',
55                         require => Package['dupload'],
56                 }
57                 include ferm::ftp_conntrack
58
59
60                 #
61                 # Aptitude killer
62                 #
63                 package { 'python-psutil':
64                         ensure => installed,
65                 }
66                 file { '/usr/local/sbin/buildd-schroot-aptitude-kill':
67                         source  => 'puppet:///modules/buildd/buildd-schroot-aptitude-kill',
68                         mode    => '0555',
69                 }
70
71                 concat::fragment { 'dsa-puppet-stuff--buildd-aptitude-killer':
72                         target => '/etc/cron.d/dsa-puppet-stuff',
73                         content  => @(EOF)
74                                 */5 * * * * root /usr/local/sbin/buildd-schroot-aptitude-kill
75                                 | EOF
76                 }
77
78
79                 #
80                 # GPG/SSH key generation
81                 #
82                 file { '/home/buildd/.gnupg':
83                         ensure  => directory,
84                         mode    => '700',
85                         group   => buildd,
86                         owner   => buildd,
87                 }
88                 file { '/home/buildd/.gnupg/gpg.conf':
89                         content  => "personal-digest-preferences SHA512\n",
90                         group   => buildd,
91                         owner   => buildd,
92                 }
93
94                 ssh::keygen {'buildd': }
95
96                 #
97                 # buildd/pybuildd configuration
98                 #
99                 if $::hostname in [x86-grnet-01,x86-grnet-02,zani] {
100                         #
101                         # pybuildd configuration
102                         #
103                         package { 'buildd':
104                                 ensure => purged,
105                         }
106
107                         package { ['python3-retrying', 'python3-yaml']:
108                                 ensure => installed,
109                         }
110                         file { '/home/buildd/.profile':
111                                 content  => @(EOT),
112                                         export XDG_RUNTIME_DIR="/run/user/$(id -u)"
113                                         export DBUS_SESSION_BUS_ADDRESS="unix:path=${XDG_RUNTIME_DIR}/bus"
114                                         | EOT
115                                 group   => buildd,
116                                 owner   => buildd,
117                         }
118                         file { '/home/buildd/logs':
119                                 ensure  => directory,
120                                 mode    => '2750',
121                                 group   => buildd,
122                                 owner   => buildd,
123                         }
124                         file { '/var/lib/systemd/linger':
125                                 ensure  => directory,
126                                 mode    => '755',
127                         }
128                         file { "/var/lib/systemd/linger/buildd":
129                                 ensure => present,
130                         }
131                         file { '/etc/systemd/journald.conf.d':
132                                 ensure  => directory,
133                                 mode    => '755',
134                         }
135                         file { '/etc/systemd/journald.conf.d/persistency.conf':
136                                 source => 'puppet:///modules/dsa_systemd/persistency.conf',
137                         }
138
139                         # Make sure that the build directory have the correct permissions.
140                         # This should go away once pybuildd issue #3 is solved.
141                         file { '/home/buildd/build':
142                                 ensure  => directory,
143                                 mode    => '2750',
144                                 group   => buildd,
145                                 owner   => buildd,
146                         }
147                         # work around https://salsa.debian.org/wb-team/pybuildd/issues/11
148                         concat::fragment { 'dsa-puppet-stuff--pybuildd-expire-logs':
149                                 target => '/etc/cron.d/dsa-puppet-stuff',
150                                 content  => @(EOF)
151                                         @daily buildd [ -d ~buildd/logs ] && find ~buildd/logs -type f -mtime +90 -delete
152                                         | EOF
153                         }
154                 } else {
155                         #
156                         # buildd configuration
157                         #
158                         file { '/home/buildd/build':
159                                 ensure  => directory,
160                                 mode    => '2750',
161                                 group   => buildd,
162                                 owner   => buildd,
163                         }
164                         file { '/home/buildd/logs':
165                                 ensure  => directory,
166                                 mode    => '2750',
167                                 group   => buildd,
168                                 owner   => buildd,
169                         }
170                         file { '/home/buildd/old-logs':
171                                 ensure  => directory,
172                                 mode    => '2750',
173                                 group   => buildd,
174                                 owner   => buildd,
175                         }
176                         file { '/home/buildd/upload-security':
177                                 ensure  => directory,
178                                 mode    => '2750',
179                                 group   => buildd,
180                                 owner   => buildd,
181                         }
182                         file { '/home/buildd/stats':
183                                 ensure  => directory,
184                                 mode    => '2755',
185                                 group   => buildd,
186                                 owner   => buildd,
187                         }
188                         file { '/home/buildd/stats/graphs':
189                                 ensure  => directory,
190                                 mode    => '2755',
191                                 group   => buildd,
192                                 owner   => buildd,
193                         }
194                         file { '/home/buildd/upload':
195                                 ensure  => directory,
196                                 mode    => '2755',
197                                 group   => buildd,
198                                 owner   => buildd,
199                         }
200                         file { '/home/buildd/.forward':
201                                 content  => "|/usr/bin/buildd-mail\n",
202                                 group   => buildd,
203                                 owner   => buildd,
204                         }
205
206                         package { 'buildd':
207                                 ensure => installed,
208                         }
209                         file { '/etc/buildd/buildd.conf':
210                                 source  => 'puppet:///modules/buildd/buildd.conf',
211                                 require => Package['buildd'],
212                         }
213
214                         concat::fragment { 'dsa-puppet-stuff--buildd':
215                                 target => '/etc/cron.d/dsa-puppet-stuff',
216                                 source  => 'puppet:///modules/buildd/cron.d-dsa-buildd',
217                                 require => Package['debian.org']
218                         }
219                         service { 'buildd':
220                                 enable => false,
221                                 ensure => 'stopped',
222                         }
223                 }
224         }
225 }