Skip to content

Commit 9876c31

Browse files
jps-helpjamesps-ebibastelfreak
authored
Add support for deb822 APT sources (#1167)
* Initial testing for deb822 APT sources * Added defined type for generating deb822 apt sources Should be roughly drop-in alternative to the existing apt::source type Does not currently support inline ascii gpg key * Add puppet strings documentation * Replace example with generic content * Initial testing of apt::source with deb822 support * Fix setting_type and signed_by Use 'sources' instead of 'source' as the setting_type parsed to apt::setting Fix the data type of apt::source::signed_by * Fix source_deb822.epp template Correctly handle newline/whitespace trimming for `signed_by` parameter. * Remove link from components to repos * Add logic for deb822 sources * Update documentation for deb822 sources * Update source_format parameter Match the possible values to the file suffix of the created source files. * Add forward-compatibility with deb822 Allow array values for certain parameters to allow easy switching between .list and .sources formats. * Add backward-compatibility for deb822 sources Convert string values to arrays where possible and warn the user. * Fix logic * Revert "Add forward-compatibility with deb822" This reverts commit 9d88e93. * Fix deb822 backward compatibility Correctly compare data type when generating deb822 sources Remove unused class parameters and descriptions * Update puppet-strings and logic Remove references to unused deb822 parameters Update parameter descriptions Update deb822 example Update warnings for $pin and $key usage with deb822. Currently unsupported Don't fail if $location is missing unless $ensure is 'present' * Remove unused spec test * Add unit testing for deb822 sources * Update README.md with deb822 sources example * Fix unit test syntax * Re-apply commit 2faa817 eliminate params.pp and create_resources() params.pp and create_resources() are obsolete. This module was converted to non-params.pp style #667, but was reverted in #680. Using Hiera in modules and no params.pp are the preferred styles these days. * Update apt::config_files hash Add support for deb822 .sources files * Update data types and documentation Re-apply data-type changes for apt::source::pin from 1e1baad Regenerate puppet strings to match. * Update source_deb822.epp template Remove leading whitespace * Update manifests/setting.pp Simplify apt::setting logic Co-authored-by: Tim Meusel <[email protected]> --------- Co-authored-by: James Paton-Smith <[email protected]> Co-authored-by: Tim Meusel <[email protected]>
1 parent 30e8065 commit 9876c31

File tree

7 files changed

+439
-154
lines changed

7 files changed

+439
-154
lines changed

README.md

+21
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,27 @@ apt::source { 'puppetlabs':
225225

226226
<a id="configure-apt-from-hiera"></a>
227227

228+
### Generating a DEB822 .sources file
229+
230+
You can also generate a DEB822 format .sources file. This example covers most of the available options.
231+
232+
Use the `source_format` parameter to choose between 'list' and 'sources' (DEB822) formats.
233+
```puppet
234+
apt::source { 'debian':
235+
source_format => 'sources'
236+
comment => 'Official Debian Repository',
237+
enabled => true,
238+
types => ['deb', 'deb-src'],
239+
location => ['http://fr.debian.org/debian', 'http://de.debian.org/debian']
240+
release => ['stable', 'stable-updates', 'stable-backports'],
241+
repos => ['main', 'contrib', 'non-free'],
242+
architecture => ['amd64', 'i386'],
243+
allow_unsigned => true,
244+
keyring => '/etc/apt/keyrings/debian.gpg'
245+
notify_update => false
246+
}
247+
```
248+
228249
### Configure Apt from Hiera
229250

230251
Instead of specifying your sources directly as resources, you can instead just include the `apt` class, which will pick up the values automatically from hiera.

REFERENCE.md

+57-11
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,10 @@ Default value:
402402
'path' => $sources_list_d,
403403
'ext' => '.list',
404404
},
405+
'sources' => {
406+
'path' => $sources_list_d,
407+
'ext' => '.sources',
408+
},
405409
}
406410
```
407411

@@ -1088,11 +1092,25 @@ apt::source { 'puppetlabs':
10881092
}
10891093
```
10901094

1095+
##### Install the puppetlabs apt source (deb822 format)
1096+
1097+
```puppet
1098+
apt::source { 'puppetlabs':
1099+
source_format => 'sources'
1100+
location => ['http://apt.puppetlabs.com'],
1101+
repos => ['puppet8'],
1102+
keyring => '/etc/apt/keyrings/puppetlabs.gpg',
1103+
}
1104+
```
1105+
10911106
#### Parameters
10921107

10931108
The following parameters are available in the `apt::source` defined type:
10941109

1110+
* [`source_format`](#-apt--source--source_format)
10951111
* [`location`](#-apt--source--location)
1112+
* [`types`](#-apt--source--types)
1113+
* [`enabled`](#-apt--source--enabled)
10961114
* [`comment`](#-apt--source--comment)
10971115
* [`ensure`](#-apt--source--ensure)
10981116
* [`release`](#-apt--source--release)
@@ -1107,14 +1125,39 @@ The following parameters are available in the `apt::source` defined type:
11071125
* [`notify_update`](#-apt--source--notify_update)
11081126
* [`check_valid_until`](#-apt--source--check_valid_until)
11091127

1128+
##### <a name="-apt--source--source_format"></a>`source_format`
1129+
1130+
Data type: `Enum['list', 'sources']`
1131+
1132+
The file format to use for the apt source. See https://wiki.debian.org/SourcesList
1133+
1134+
Default value: `'list'`
1135+
11101136
##### <a name="-apt--source--location"></a>`location`
11111137

1112-
Data type: `Optional[String[1]]`
1138+
Data type: `Optional[Variant[String[1], Array[String[1]]]]`
11131139

1114-
Required, unless ensure is set to 'absent'. Specifies an Apt repository.
1140+
Required, unless ensure is set to 'absent'. Specifies an Apt repository. Valid options: a string containing a repository URL.
1141+
DEB822: Supports an array of URL values
11151142

11161143
Default value: `undef`
11171144

1145+
##### <a name="-apt--source--types"></a>`types`
1146+
1147+
Data type: `Array[Enum['deb','deb-src'], 1, 2]`
1148+
1149+
DEB822: The package types this source manages.
1150+
1151+
Default value: `['deb']`
1152+
1153+
##### <a name="-apt--source--enabled"></a>`enabled`
1154+
1155+
Data type: `Boolean`
1156+
1157+
DEB822: Enable or Disable the APT source.
1158+
1159+
Default value: `true`
1160+
11181161
##### <a name="-apt--source--comment"></a>`comment`
11191162

11201163
Data type: `String[1]`
@@ -1133,17 +1176,19 @@ Default value: `present`
11331176

11341177
##### <a name="-apt--source--release"></a>`release`
11351178

1136-
Data type: `Optional[String[0]]`
1179+
Data type: `Optional[Variant[String[0], Array[String[0]]]]`
11371180

11381181
Specifies a distribution of the Apt repository.
1182+
DEB822: Supports an array of values
11391183

11401184
Default value: `undef`
11411185

11421186
##### <a name="-apt--source--repos"></a>`repos`
11431187

1144-
Data type: `String[1]`
1188+
Data type: `Variant[String[1], Array[String[1]]]`
11451189

11461190
Specifies a component of the Apt repository.
1191+
DEB822: Supports an array of values
11471192

11481193
Default value: `'main'`
11491194

@@ -1194,29 +1239,30 @@ Default value: `undef`
11941239

11951240
##### <a name="-apt--source--architecture"></a>`architecture`
11961241

1197-
Data type: `Optional[String[1]]`
1242+
Data type: `Optional[Variant[String[1], Array[String[1]]]]`
11981243

11991244
Tells Apt to only download information for specified architectures. Valid options: a string containing one or more architecture names,
12001245
separated by commas (e.g., 'i386' or 'i386,alpha,powerpc').
12011246
(if unspecified, Apt downloads information for all architectures defined in the Apt::Architectures option)
1247+
DEB822: Supports an array of values
12021248

12031249
Default value: `undef`
12041250

12051251
##### <a name="-apt--source--allow_unsigned"></a>`allow_unsigned`
12061252

1207-
Data type: `Boolean`
1253+
Data type: `Optional[Boolean]`
12081254

12091255
Specifies whether to authenticate packages from this release, even if the Release file is not signed or the signature can't be checked.
12101256

1211-
Default value: `false`
1257+
Default value: `undef`
12121258

12131259
##### <a name="-apt--source--allow_insecure"></a>`allow_insecure`
12141260

1215-
Data type: `Boolean`
1261+
Data type: `Optional[Boolean]`
12161262

12171263
Specifies whether to allow downloads from insecure repositories.
12181264

1219-
Default value: `false`
1265+
Default value: `undef`
12201266

12211267
##### <a name="-apt--source--notify_update"></a>`notify_update`
12221268

@@ -1228,11 +1274,11 @@ Default value: `true`
12281274

12291275
##### <a name="-apt--source--check_valid_until"></a>`check_valid_until`
12301276

1231-
Data type: `Boolean`
1277+
Data type: `Optional[Boolean]`
12321278

12331279
Specifies whether to check if the package release date is valid.
12341280

1235-
Default value: `true`
1281+
Default value: `undef`
12361282

12371283
## Data types
12381284

manifests/init.pp

+4
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,10 @@
213213
'path' => $sources_list_d,
214214
'ext' => '.list',
215215
},
216+
'sources' => {
217+
'path' => $sources_list_d,
218+
'ext' => '.sources',
219+
},
216220
},
217221
Boolean $sources_list_force = false,
218222
Hash $source_key_defaults = {

manifests/setting.pp

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
$setting_type = $title_array[0]
4141
$base_name = join(delete_at($title_array, 0), '-')
4242

43-
assert_type(Pattern[/\Aconf\z/, /\Apref\z/, /\Alist\z/], $setting_type) |$a, $b| {
44-
fail("apt::setting resource name/title must start with either 'conf-', 'pref-' or 'list-'")
43+
assert_type(Pattern[/\Aconf\z/, /\Apref\z/, /\Alist\z/, /\Asources\z/], $setting_type) |$a, $b| {
44+
fail("apt::setting resource name/title must start with either 'conf-', 'pref-', 'list-', or 'sources-'")
4545
}
4646

4747
if $priority !~ Integer {
@@ -51,7 +51,7 @@
5151
}
5252
}
5353

54-
if ($setting_type == 'list') or ($setting_type == 'pref') {
54+
if $setting_type in ['list', 'pref', 'sources'] {
5555
$_priority = ''
5656
} else {
5757
$_priority = $priority

0 commit comments

Comments
 (0)