|
24 | 24 | # @example Install the puppetlabs apt source (deb822 format)
|
25 | 25 | # apt::source { 'puppetlabs':
|
26 | 26 | # source_format => 'sources'
|
27 |
| -# uris => ['http://apt.puppetlabs.com'], |
28 |
| -# suites => [$facts['os']['distro']['codename']], |
29 |
| -# components => ['puppet8'], |
30 |
| -# signed_by => '/etc/apt/keyrings/puppetlabs.gpg', |
| 27 | +# location => ['http://apt.puppetlabs.com'], |
| 28 | +# repos => ['puppet8'], |
| 29 | +# keyring => '/etc/apt/keyrings/puppetlabs.gpg', |
31 | 30 | # }
|
32 | 31 | #
|
33 | 32 | # @param source_format
|
34 | 33 | # The file format to use for the apt source. See https://wiki.debian.org/SourcesList
|
35 | 34 | #
|
36 | 35 | # @param location
|
37 | 36 | # Required, unless ensure is set to 'absent'. Specifies an Apt repository. Valid options: a string containing a repository URL.
|
| 37 | +# DEB822: Supports an array of URL values |
38 | 38 | #
|
39 | 39 | # @param types
|
40 | 40 | # DEB822: The package types this source manages.
|
41 | 41 | #
|
42 |
| -# @param uris |
43 |
| -# DEB822: A list of URIs for the APT source. |
44 |
| -# |
45 | 42 | # @param enabled
|
46 | 43 | # DEB822: Enable or Disable the APT source.
|
47 | 44 | #
|
|
53 | 50 | #
|
54 | 51 | # @param release
|
55 | 52 | # Specifies a distribution of the Apt repository.
|
56 |
| -# |
57 |
| -# @param suites |
58 |
| -# DEB822: A list of suites for the APT source ('jammy-updates', 'bookworm', 'stable', etc.). |
| 53 | +# DEB822: Supports an array of values |
59 | 54 | #
|
60 | 55 | # @param repos
|
61 | 56 | # Specifies a component of the Apt repository.
|
62 |
| -# |
63 |
| -# @param components |
64 |
| -# DEB822: A list of components for the APT source ('main', 'contrib', 'non-free', etc.). |
| 57 | +# DEB822: Supports an array of values |
65 | 58 | #
|
66 | 59 | # @param include
|
67 | 60 | # Configures include options. Valid options: a hash of available keys.
|
|
85 | 78 | # This is not necessary if the key is installed with `key` param above.
|
86 | 79 | # See https://wiki.debian.org/DebianRepository/UseThirdParty for details.
|
87 | 80 | #
|
88 |
| -# @param signed_by |
89 |
| -# DEB822: Either an absolute path to a PGP keyring file used to sign this repository OR a list of key fingerprints to trust. |
90 |
| -# |
91 | 81 | # @param pin
|
92 | 82 | # Creates a declaration of the apt::pin defined type. Valid options: a number or string to be passed to the `id` parameter of the
|
93 | 83 | # `apt::pin` defined type, or a hash of `parameter => value` pairs to be passed to `apt::pin`'s corresponding parameters.
|
|
96 | 86 | # Tells Apt to only download information for specified architectures. Valid options: a string containing one or more architecture names,
|
97 | 87 | # separated by commas (e.g., 'i386' or 'i386,alpha,powerpc').
|
98 | 88 | # (if unspecified, Apt downloads information for all architectures defined in the Apt::Architectures option)
|
99 |
| -# |
100 |
| -# @param architectures |
101 |
| -# DEB822: A list of supported architectures for the APT source ('amd64', 'i386', etc.). |
| 89 | +# DEB822: Supports an array of values |
102 | 90 | #
|
103 | 91 | # @param allow_unsigned
|
104 | 92 | # Specifies whether to authenticate packages from this release, even if the Release file is not signed or the signature can't be checked.
|
105 | 93 | #
|
106 |
| -# @param repo_trusted |
107 |
| -# DEB822: Consider the APT source trusted, even if authentication checks fail. |
108 |
| -# |
109 | 94 | # @param allow_insecure
|
110 | 95 | # Specifies whether to allow downloads from insecure repositories.
|
111 | 96 | #
|
|
116 | 101 | # Specifies whether to check if the package release date is valid. Defaults to `True`.
|
117 | 102 | #
|
118 | 103 | define apt::source (
|
119 |
| - Enum['list', 'sources'] $source_format = 'list', |
120 |
| - Array[Enum['deb','deb-src'], 1, 2] $types = ['deb'], |
121 |
| - Optional[String] $location = undef, |
122 |
| - Optional[Array[String]] $uris = undef, # deb822 |
123 |
| - Boolean $enabled = true, # deb822 |
124 |
| - String $comment = $name, |
125 |
| - String $ensure = present, |
126 |
| - Optional[String] $release = undef, |
127 |
| - Optional[Array[String]] $suites = undef, # deb822 |
128 |
| - String $repos = 'main', |
129 |
| - Optional[Array[String]] $components = undef, # deb822 |
130 |
| - Variant[Hash] $include = {}, |
131 |
| - Optional[Variant[String, Hash]] $key = undef, |
132 |
| - Optional[Stdlib::AbsolutePath] $keyring = undef, |
133 |
| - Optional[Variant[Stdlib::AbsolutePath,Array[String]]] $signed_by = undef, # deb822 |
134 |
| - Optional[Variant[Hash, Numeric, String]] $pin = undef, |
135 |
| - Optional[String] $architecture = undef, |
136 |
| - Optional[Array[String]] $architectures = undef, # deb822 |
137 |
| - Optional[Boolean] $allow_unsigned = undef, |
138 |
| - Optional[Boolean] $repo_trusted = undef, # deb822 |
139 |
| - Optional[Boolean] $allow_insecure = undef, |
140 |
| - Optional[Boolean] $check_valid_until = undef, |
141 |
| - Boolean $notify_update = true, |
| 104 | + Enum['list', 'sources'] $source_format = 'list', |
| 105 | + Array[Enum['deb','deb-src'], 1, 2] $types = ['deb'], |
| 106 | + Optional[Variant[String, Array[String]]] $location = undef, |
| 107 | + Boolean $enabled = true, # deb822 |
| 108 | + String $comment = $name, |
| 109 | + String $ensure = present, |
| 110 | + Optional[Variant[String, Array[String]]] $release = undef, |
| 111 | + Variant[String, Array[String]] $repos = 'main', |
| 112 | + Variant[Hash] $include = {}, |
| 113 | + Optional[Variant[String, Hash]] $key = undef, |
| 114 | + Optional[Stdlib::AbsolutePath] $keyring = undef, |
| 115 | + Optional[Variant[Hash, Numeric, String]] $pin = undef, |
| 116 | + Optional[Variant[String, Array[String]]] $architecture = undef, |
| 117 | + Optional[Boolean] $allow_unsigned = undef, |
| 118 | + Optional[Boolean] $allow_insecure = undef, |
| 119 | + Optional[Boolean] $check_valid_until = undef, |
| 120 | + Boolean $notify_update = true, |
142 | 121 | ) {
|
143 | 122 | include apt
|
144 | 123 |
|
|
293 | 272 | }
|
294 | 273 | }
|
295 | 274 | 'sources': {
|
| 275 | + $_file_suffix = $source_format |
| 276 | + |
296 | 277 | if $pin {
|
297 |
| - fail('apt::source::pin parameter is not supported with deb822 format') |
| 278 | + warning("'pin' parameter is not supported with deb822 format.") |
298 | 279 | }
|
299 |
| - if !$uris { |
300 |
| - fail('You must specify a list of URIs for the apt::source resource') |
| 280 | + if $key { |
| 281 | + warning("'key' parameter is not supported with deb822 format.") |
301 | 282 | }
|
302 |
| - if !$suites { |
303 |
| - fail('You must specify a list of suites for the apt::source resource') |
| 283 | + if $ensure == 'present' { |
| 284 | + if ! $location { |
| 285 | + fail('cannot create a source entry without specifying a location') |
| 286 | + } |
304 | 287 | }
|
305 |
| - if !$components { |
306 |
| - fail('You must specify a list of components for the apt::source resource') |
| 288 | + if (type($location, 'generalized') !~ Type[Array]) { |
| 289 | + warning('For deb822 sources, location must be specified as an array.') |
| 290 | + $_location = [$location] |
| 291 | + } |
| 292 | + else { |
| 293 | + $_location = $location |
| 294 | + } |
| 295 | + |
| 296 | + if !$release { |
| 297 | + if fact('os.distro.codename') { |
| 298 | + $_release = [fact('os.distro.codename')] |
| 299 | + } else { |
| 300 | + fail('os.distro.codename fact not available: release parameter required') |
| 301 | + } |
| 302 | + } else { |
| 303 | + if (type($release, 'generalized') !~ Type[Array]) { |
| 304 | + warning("For deb822 sources, 'release' must be specified as an array. Converting to array.") |
| 305 | + $_release = [$release] |
| 306 | + } else { |
| 307 | + $_release = $release |
| 308 | + } |
| 309 | + } |
| 310 | + |
| 311 | + if (type($repos, 'generalized') !~ Type[Array]) { |
| 312 | + warning("For deb822 sources, 'repos' must be specified as an array. Converting to array.") |
| 313 | + $_repos = split($repos, /\s+/) |
| 314 | + } else { |
| 315 | + $_repos = $repos |
| 316 | + } |
| 317 | + |
| 318 | + if $architecture != undef { |
| 319 | + if (type($architecture, 'generalized') !~ Type[Array]) { |
| 320 | + warning("For deb822 sources, 'architecture' must be specified as an array. Converting to array.") |
| 321 | + $_architecture = split($architecture, '[,]') |
| 322 | + } |
| 323 | + else { |
| 324 | + $_architecture = $architecture |
| 325 | + } |
| 326 | + } else { |
| 327 | + $_architecture = $architecture |
307 | 328 | }
|
308 |
| - $_file_suffix = $source_format |
309 | 329 | case $ensure {
|
310 | 330 | 'present': {
|
311 | 331 | $header = epp('apt/_header.epp')
|
312 | 332 | $source_content = epp('apt/source_deb822.epp', delete_undef_values({
|
313 |
| - 'uris' => $uris, |
314 |
| - 'suites' => $suites, |
315 |
| - 'components' => $components, |
| 333 | + 'uris' => $_location, |
| 334 | + 'suites' => $_release, |
| 335 | + 'components' => $_repos, |
316 | 336 | 'types' => $types,
|
317 | 337 | 'comment' => $comment,
|
318 | 338 | 'enabled' => $enabled ? { true => 'yes', false => 'no' },
|
319 |
| - 'architectures' => $architectures, |
| 339 | + 'architectures' => $_architecture, |
320 | 340 | 'allow_insecure' => $allow_insecure ? { true => 'yes', false => 'no', default => undef },
|
321 |
| - 'repo_trusted' => $repo_trusted ? { true => 'yes', false => 'no', default => undef }, |
| 341 | + 'repo_trusted' => $allow_unsigned ? { true => 'yes', false => 'no', default => undef }, |
322 | 342 | 'check_valid_until' => $check_valid_until ? { true => 'yes', false => 'no', default => undef },
|
323 |
| - 'signed_by' => $signed_by, |
| 343 | + 'signed_by' => $keyring, |
324 | 344 | }
|
325 | 345 | )
|
326 | 346 | )
|
|
0 commit comments