Puppet Class: aptrepo

Defined in:
modules/aptrepo/manifests/init.pp

Overview

Class: aptrepo

Configures apt.wikimedia.org and reprepro on a server

Parameters

- *basedir*: The reprepro base directory.
- *homedir*: The reprepro user home directory.
- *user*: The user name to run reprepro under.
- *group*: The group name to run reprepro under.
- *notify_address*: Where to send upload notifications.
- *options*: A list of options for reprepro (see conf/options file).
- *uploaders*: A list of uploaders instructions (see "uploaders file")
- *incomingdir*: Path considered for incoming uploads.
- *incomingconf*: Name of a template with config options for incoming uploads. (conf/incoming)
- *incominguser*: The user name that owns the incoming directory.
- *incominggroup*: The group name that owns the incoming directory.
- *default_distro*: The default distribution if none specified.
- *gpg_secring*: The GPG secret keyring for reprepro to use. Will be passed to secret()
- *gpg_pubring*: The GPG public keyring for reprepro to use. Will be passed to secret()
- *authorized_keys*: A list of ssh public keys allowed to upload and process the incoming queue

Example

class { 'aptrepo':
    basedir => "/tmp/reprepro",
}

TODO: add something that sets up /etc/environment for reprepro

Parameters:

  • basedir (Any)
  • homedir (Any) (defaults to: '/var/lib/reprepro')
  • user (Any) (defaults to: 'reprepro')
  • group (Any) (defaults to: 'reprepro')
  • notify_address (Any) (defaults to: 'root@wikimedia.org')
  • options (Any) (defaults to: [])
  • uploaders (Any) (defaults to: [])
  • incomingdir (Any) (defaults to: 'incoming')
  • incomingconf (Any) (defaults to: 'incoming')
  • incominguser (Any) (defaults to: 'reprepro')
  • incominggroup (Any) (defaults to: 'reprepro')
  • default_distro (Any) (defaults to: 'jessie')
  • gpg_secring (Any) (defaults to: undef)
  • gpg_pubring (Any) (defaults to: undef)
  • gpg_user (Any) (defaults to: undef)
  • authorized_keys (Any) (defaults to: [])


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
# File 'modules/aptrepo/manifests/init.pp', line 31

class aptrepo (
    $basedir,
    $homedir         = '/var/lib/reprepro',
    $user            = 'reprepro',
    $group           = 'reprepro',
    $notify_address  = 'root@wikimedia.org',
    $options         = [],
    $uploaders       = [],
    $incomingdir     = 'incoming',
    $incomingconf    = 'incoming',
    $incominguser    = 'reprepro',
    $incominggroup   = 'reprepro',
    $default_distro  = 'jessie',
    $gpg_secring     = undef,
    $gpg_pubring     = undef,
    $gpg_user        = undef,
    $authorized_keys = [],
) {

    package { 'reprepro':
        ensure => present,
    }

    if os_version('debian >= buster') {
        require_package('python-apt')
    }

    $deb822_validate_cmd = '/usr/bin/python -c "import apt_pkg; f=\'%\'; list(apt_pkg.TagFile(f))"'

    file { $basedir:
        ensure => directory,
        owner  => 'root',
        group  => 'root',
        mode   => '0755',
    }

    file { "${basedir}/conf":
        ensure => directory,
        owner  => 'root',
        group  => 'root',
        mode   => '0755',
    }

    file { "${basedir}/conf/updates":
        ensure       => present,
        mode         => '0444',
        owner        => 'root',
        group        => 'root',
        source       => 'puppet:///modules/aptrepo/updates',
        validate_cmd => $deb822_validate_cmd,
    }

    file { "${basedir}/conf/pulls":
        ensure       => present,
        mode         => '0444',
        owner        => 'root',
        group        => 'root',
        source       => 'puppet:///modules/aptrepo/pulls',
        validate_cmd => $deb822_validate_cmd,
    }

    file { "${basedir}/conf/options":
        ensure       => file,
        owner        => $user,
        group        => $group,
        mode         => '0444',
        content      => inline_template("<%= @options.join(\"\n\") %>\n"),
        validate_cmd => $deb822_validate_cmd,
    }

    file { "${basedir}/conf/uploaders":
        ensure       => file,
        owner        => $user,
        group        => $group,
        mode         => '0444',
        content      => inline_template("<%= @uploaders.join(\"\n\") %>\n"),
        validate_cmd => $deb822_validate_cmd,
    }

    file { "${basedir}/conf/incoming":
        ensure       => present,
        owner        => 'root',
        group        => 'root',
        mode         => '0444',
        content      => template("aptrepo/${incomingconf}.erb"),
        validate_cmd => $deb822_validate_cmd,
    }

    file { "${basedir}/conf/log":
        ensure  => present,
        owner   => 'root',
        group   => 'root',
        mode    => '0755',
        content => template('aptrepo/log.erb'),
    }

    file { "${basedir}/db":
        ensure  => directory,
        owner   => $user,
        group   => $group,
        mode    => '0755',
        require => User['reprepro'],
    }

    file { "${basedir}/incoming":
        ensure => directory,
        mode   => '1775',
        owner  => $incominguser,
        group  => $incominggroup,
    }

    file { "${basedir}/logs":
        ensure  => directory,
        owner   => $user,
        group   => $group,
        mode    => '0755',
        require => User['reprepro'],
    }

    file { "${basedir}/tmp":
        ensure  => directory,
        owner   => $user,
        group   => $group,
        mode    => '0755',
        require => User['reprepro'],
    }

    file { "${homedir}/.gnupg":
        ensure  => directory,
        owner   => $gpg_user,
        group   => $gpg_user,
        mode    => '0700',
        require => User['reprepro'],
    }

    ssh::userkey { 'reprepro':
        content => template('aptrepo/authorized_keys.erb'),
    }

    file { '/usr/local/bin/reprepro-ssh-upload':
        ensure  => file,
        owner   => 'root',
        group   => 'root',
        mode    => '0555',
        require => User['reprepro'],
        source  => 'puppet:///modules/aptrepo/reprepro-ssh-upload',
    }

    if $gpg_secring != undef {
        file { "${homedir}/.gnupg/secring.gpg":
            ensure    => file,
            owner     => $gpg_user,
            group     => $gpg_user,
            mode      => '0400',
            content   => secret($gpg_secring),
            show_diff => false,
            require   => User['reprepro'],
        }
    }

    if $gpg_pubring != undef {
        file { "${homedir}/.gnupg/pubring.gpg":
            ensure  => file,
            owner   => $gpg_user,
            group   => $gpg_user,
            mode    => '0400',
            content => secret($gpg_pubring),
            require => User['reprepro'],
        }
    }

    # mail(1) is needed to send a notification mail after package imports
    if os_version('debian >= buster') {
        require_package('bsd-mailx')
    }

    # apt repository managements tools
    package { [
        'dpkg-dev',
        'dctrl-tools',
        'gnupg',
        ]:
        ensure => present,
    }

    file_line { 'reprepro_basedir':
      ensure => present,
      path   => '/root/.bashrc',
      line   => "export REPREPRO_BASE_DIR=${basedir}  # Managed by puppet",
    }

    # We also need /srv/tftboot populated from volatile on APT repo servers,
    # not just install (TFTP) servers because installer files are fetched via HTTP (T252382)
    file { '/srv/tftpboot':
        # config files in the puppet repository,
        # larger files like binary images in volatile
        source       => [
            'puppet:///modules/install_server/tftpboot',
            # lint:ignore:puppet_url_without_modules
            'puppet:///volatile/tftpboot',
            # lint:endignore
        ],
        sourceselect => all,
        mode         => '0444',
        owner        => 'root',
        group        => 'root',
        recurse      => remote,
        backup       => false,
    }
}