0338a1f99274ed0a769b397c81720ed1dbb51978
[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                 if ! $::buildd_key {
95                         exec { 'create-buildd-key':
96                                 command => '/bin/su - buildd -c \'mkdir -p -m 02700 .ssh && ssh-keygen -C "`whoami`@`hostname` (`date +%Y-%m-%d`)" -P "" -f .ssh/id_rsa -q\'',
97                                 onlyif  => '/usr/bin/getent passwd buildd > /dev/null && ! [ -e /home/buildd/.ssh/id_rsa ]'
98                         }
99                 }
100
101
102                 #
103                 # buildd configuration
104                 #
105                 file { '/home/buildd/build':
106                         ensure  => directory,
107                         mode    => '2750',
108                         group   => buildd,
109                         owner   => buildd,
110                 }
111                 file { '/home/buildd/logs':
112                         ensure  => directory,
113                         mode    => '2750',
114                         group   => buildd,
115                         owner   => buildd,
116                 }
117                 file { '/home/buildd/old-logs':
118                         ensure  => directory,
119                         mode    => '2750',
120                         group   => buildd,
121                         owner   => buildd,
122                 }
123                 file { '/home/buildd/upload-security':
124                         ensure  => directory,
125                         mode    => '2750',
126                         group   => buildd,
127                         owner   => buildd,
128                 }
129                 file { '/home/buildd/stats':
130                         ensure  => directory,
131                         mode    => '2755',
132                         group   => buildd,
133                         owner   => buildd,
134                 }
135                 file { '/home/buildd/stats/graphs':
136                         ensure  => directory,
137                         mode    => '2755',
138                         group   => buildd,
139                         owner   => buildd,
140                 }
141                 file { '/home/buildd/upload':
142                         ensure  => directory,
143                         mode    => '2755',
144                         group   => buildd,
145                         owner   => buildd,
146                 }
147                 file { '/home/buildd/.forward':
148                         content  => "|/usr/bin/buildd-mail\n",
149                         group   => buildd,
150                         owner   => buildd,
151                 }
152
153                 package { 'buildd':
154                         ensure => installed,
155                 }
156                 file { '/etc/buildd/buildd.conf':
157                         source  => 'puppet:///modules/buildd/buildd.conf',
158                         require => Package['buildd'],
159                 }
160
161                 if (versioncmp($::lsbmajdistrelease, '9') >= 0) {
162                         site::aptrepo { 'buildd.debian.org':
163                                 ensure => absent,
164                         }
165                         file { '/etc/apt/apt.conf.d/puppet-https-buildd':
166                                 ensure => absent,
167                         }
168                 } else {
169                         site::aptrepo { 'buildd.debian.org':
170                                 key        => 'puppet:///modules/buildd/buildd.debian.org.gpg',
171                                 url        => 'https://apt.buildd.debian.org/',
172                                 suite      => 'jessie',
173                                 components => 'main',
174                                 require    => Package['apt-transport-https'],
175                         }
176                         file { '/etc/apt/apt.conf.d/puppet-https-buildd':
177                                 content => "Acquire::https::apt.buildd.debian.org::CaInfo \"/etc/ssl/ca-debian/ca-certificates.crt\";\n",
178                         }
179                 }
180
181                 concat::fragment { 'dsa-puppet-stuff--buildd':
182                         target => '/etc/cron.d/dsa-puppet-stuff',
183                         source  => 'puppet:///modules/buildd/cron.d-dsa-buildd',
184                         require => Package['debian.org']
185                 }
186                 service { 'buildd':
187                         enable => false,
188                         ensure => 'stopped',
189                 }
190
191
192                 #
193                 # pybuildd configuration
194                 #
195                 file { '/home/buildd/.profile':
196                         content  => @(EOT),
197                                 export XDG_RUNTIME_DIR="/run/user/$(id -u)"
198                                 export DBUS_SESSION_BUS_ADDRESS="unix:path=${XDG_RUNTIME_DIR}/bus"
199                                 | EOT
200                         group   => buildd,
201                         owner   => buildd,
202                 }
203
204                 file { '/var/lib/systemd/linger':
205                         ensure  => directory,
206                         mode    => '755',
207                 }
208                 file { "/var/lib/systemd/linger/buildd":
209                         ensure => present,
210                 }
211                 file { '/etc/systemd/journald.conf.d':
212                         ensure  => directory,
213                         mode    => '755',
214                 }
215                 file { '/etc/systemd/journald.conf.d/persistency.conf':
216                         source => 'puppet:///modules/systemd/persistency.conf',
217                 }
218         }
219 }