Defined Type: aptrepo::repo

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

Summary

Configure a reprepro apt repository on a server.

Overview

SPDX-License-Identifier: Apache-2.0

Parameters:

  • basedir (Stdlib::Unixpath) —

    The reprepro base directory.

  • distributions_file (Stdlib::Filesource) —

    the puppet location of the distributions file

  • notify_address (String) (defaults to: 'root@wikimedia.org') —

    Where to send upload notifications.

  • notify_subject (String) (defaults to: "Reprepro changes in ${title}") —

    The upload notifications subject.

  • options (Array[String]) (defaults to: []) —

    A list of options for reprepro (see conf/options file).

  • uploaders (Array[String]) (defaults to: []) —

    A list of uploaders instructions (see "uploaders file")

  • incomingdir (Optional[String]) (defaults to: undef) —

    Path considered for incoming uploads.

  • incomingconf (String) (defaults to: 'incoming-wikimedia') —

    Name of a template with config options for incoming uploads. (conf/incoming)

  • incominguser (String) (defaults to: 'root') —

    The user name that owns the incoming directory.

  • incominggroup (String) (defaults to: 'wikidev') —

    The group name that owns the incoming directory.

  • default_distro (String) (defaults to: 'bookworm') —

    The default distro to use

  • upload_keys (Array[String]) (defaults to: [])
  • support_external_updates (Boolean) (defaults to: true)


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

define aptrepo::repo (
    Stdlib::Unixpath        $basedir,
    Stdlib::Filesource      $distributions_file,
    String                  $notify_address           = 'root@wikimedia.org',
    String                  $notify_subject           = "Reprepro changes in ${title}",
    Array[String]           $options                  = [],
    Array[String]           $uploaders                = [],
    Optional[String]        $incomingdir              = undef,
    String                  $incomingconf             = 'incoming-wikimedia',
    String                  $incominguser             = 'root',
    String                  $incominggroup            = 'wikidev',
    String                  $default_distro           = 'bookworm',
    Array[String]           $upload_keys              = [],
    Boolean                 $support_external_updates = true,

) {
    $user = $aptrepo::common::user
    $group = $aptrepo::common::group

    stdlib::ensure_packages('python3-apt')
    $deb822_validate_cmd = '/usr/bin/python3 -c "import apt_pkg; f=\'%\'; list(apt_pkg.TagFile(f))"'

    wmflib::dir::mkdir_p($basedir)

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

    if $support_external_updates {
        file { "${basedir}/conf/updates":
            ensure       => file,
            mode         => '0444',
            source       => 'puppet:///modules/aptrepo/updates',
            validate_cmd => $deb822_validate_cmd,
        }

        file { "${basedir}/conf/pulls":
            ensure       => file,
            mode         => '0444',
            source       => 'puppet:///modules/aptrepo/pulls',
            validate_cmd => $deb822_validate_cmd,
        }
    } else {
        file { "${basedir}/conf/updates":
            ensure  => file,
            content => "# No external sync configured\n"
        }

        file { "${basedir}/conf/pulls":
            ensure  => file,
            content => "# No external sync configured\n"
        }
    }

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

    file { "${basedir}/conf/uploaders":
        ensure  => file,
        owner   => $user,
        group   => $group,
        mode    => '0444',
        content => epp('aptrepo/uploaders.epp', {'upload_keys' => $upload_keys}),
    }

    file { "${basedir}/conf/distributions":
        ensure       => file,
        mode         => '0444',
        owner        => 'root',
        group        => 'root',
        source       => $distributions_file,
        validate_cmd => $deb822_validate_cmd,
    }

    # Reprepro needs the deb-override file to exist.
    file { "${basedir}/conf/deb-override":
        ensure  => file,
        replace => 'no',
        mode    => '0644',
        owner   => 'root',
        group   => 'root',
    }

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

    $log_script = @("SCRIPT"/$)
    #!/bin/bash
    echo -e "reprepro changes:\n\$@" | mail -a "Auto-Submitted: auto-generated" -s "${notify_subject}" ${notify_address}
    | SCRIPT
    file { "${basedir}/conf/log":
        ensure  => file,
        owner   => 'root',
        group   => 'root',
        mode    => '0755',
        content => $log_script,
    }

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

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

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

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