Skip to content

Add support for deb822 APT sources #1167

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 26 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d318a6c
Initial testing for deb822 APT sources
jamesps-ebi Mar 6, 2024
1ff46c1
Added defined type for generating deb822 apt sources
jamesps-ebi Mar 7, 2024
3051de4
Add puppet strings documentation
jamesps-ebi Mar 7, 2024
73efbc1
Replace example with generic content
jamesps-ebi Mar 19, 2024
958bdbf
Initial testing of apt::source with deb822 support
jamesps-ebi Jun 25, 2024
2d59e6c
Fix setting_type and signed_by
jamesps-ebi Jun 25, 2024
fa48103
Fix source_deb822.epp template
jps-help Jun 25, 2024
68351d2
Remove link from components to repos
jamesps-ebi Jun 26, 2024
5aa44a1
Add logic for deb822 sources
jamesps-ebi Jul 2, 2024
e9bfb98
Update documentation for deb822 sources
jamesps-ebi Jul 2, 2024
0277fe9
Update source_format parameter
jamesps-ebi Jul 15, 2024
92c1193
Add forward-compatibility with deb822
jps-help Jul 25, 2024
fde9a1c
Add backward-compatibility for deb822 sources
jps-help Jul 25, 2024
4b57c29
Fix logic
jps-help Jul 25, 2024
e610f76
Revert "Add forward-compatibility with deb822"
jamesps-ebi Jul 29, 2024
48cb116
Fix deb822 backward compatibility
jamesps-ebi Jul 29, 2024
770d3f1
Update puppet-strings and logic
jamesps-ebi Jul 30, 2024
f809e85
Remove unused spec test
jamesps-ebi Jul 30, 2024
9bdd389
Add unit testing for deb822 sources
jamesps-ebi Jul 30, 2024
fc39d29
Update README.md with deb822 sources example
jamesps-ebi Jul 30, 2024
214eaa2
Fix unit test syntax
jamesps-ebi Jul 30, 2024
135da76
Re-apply commit 2faa817dcb05821bd9c27bbe8bf1955e6b2442f2
jamesps-ebi Aug 1, 2024
940e935
Update apt::config_files hash
jamesps-ebi Aug 1, 2024
ae62548
Update data types and documentation
jamesps-ebi Nov 18, 2024
6f66c98
Update source_deb822.epp template
jamesps-ebi Nov 18, 2024
27b25a3
Update manifests/setting.pp
jps-help Nov 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,27 @@ apt::source { 'puppetlabs':

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

### Generating a DEB822 .sources file

You can also generate a DEB822 format .sources file. This example covers most of the available options.

Use the `source_format` parameter to choose between 'list' and 'sources' (DEB822) formats.
```puppet
apt::source { 'debian':
source_format => 'sources'
comment => 'Official Debian Repository',
enabled => true,
types => ['deb', 'deb-src'],
location => ['http://fr.debian.org/debian', 'http://de.debian.org/debian']
release => ['stable', 'stable-updates', 'stable-backports'],
repos => ['main', 'contrib', 'non-free'],
architecture => ['amd64', 'i386'],
allow_unsigned => true,
keyring => '/etc/apt/keyrings/debian.gpg'
notify_update => false
}
```

### Configure Apt from Hiera

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.
Expand Down
68 changes: 57 additions & 11 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,10 @@ Default value:
'path' => $sources_list_d,
'ext' => '.list',
},
'sources' => {
'path' => $sources_list_d,
'ext' => '.sources',
},
}
```

Expand Down Expand Up @@ -1088,11 +1092,25 @@ apt::source { 'puppetlabs':
}
```

##### Install the puppetlabs apt source (deb822 format)

```puppet
apt::source { 'puppetlabs':
source_format => 'sources'
location => ['http://apt.puppetlabs.com'],
repos => ['puppet8'],
keyring => '/etc/apt/keyrings/puppetlabs.gpg',
}
```

#### Parameters

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

* [`source_format`](#-apt--source--source_format)
* [`location`](#-apt--source--location)
* [`types`](#-apt--source--types)
* [`enabled`](#-apt--source--enabled)
* [`comment`](#-apt--source--comment)
* [`ensure`](#-apt--source--ensure)
* [`release`](#-apt--source--release)
Expand All @@ -1107,14 +1125,39 @@ The following parameters are available in the `apt::source` defined type:
* [`notify_update`](#-apt--source--notify_update)
* [`check_valid_until`](#-apt--source--check_valid_until)

##### <a name="-apt--source--source_format"></a>`source_format`

Data type: `Enum['list', 'sources']`

The file format to use for the apt source. See https://wiki.debian.org/SourcesList

Default value: `'list'`

##### <a name="-apt--source--location"></a>`location`

Data type: `Optional[String[1]]`
Data type: `Optional[Variant[String[1], Array[String[1]]]]`

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

Default value: `undef`

##### <a name="-apt--source--types"></a>`types`

Data type: `Array[Enum['deb','deb-src'], 1, 2]`

DEB822: The package types this source manages.

Default value: `['deb']`

##### <a name="-apt--source--enabled"></a>`enabled`

Data type: `Boolean`

DEB822: Enable or Disable the APT source.

Default value: `true`

##### <a name="-apt--source--comment"></a>`comment`

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

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

Data type: `Optional[String[0]]`
Data type: `Optional[Variant[String[0], Array[String[0]]]]`

Specifies a distribution of the Apt repository.
DEB822: Supports an array of values

Default value: `undef`

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

Data type: `String[1]`
Data type: `Variant[String[1], Array[String[1]]]`

Specifies a component of the Apt repository.
DEB822: Supports an array of values

Default value: `'main'`

Expand Down Expand Up @@ -1194,29 +1239,30 @@ Default value: `undef`

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

Data type: `Optional[String[1]]`
Data type: `Optional[Variant[String[1], Array[String[1]]]]`

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

Default value: `undef`

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

Data type: `Boolean`
Data type: `Optional[Boolean]`

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

Default value: `false`
Default value: `undef`

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

Data type: `Boolean`
Data type: `Optional[Boolean]`

Specifies whether to allow downloads from insecure repositories.

Default value: `false`
Default value: `undef`

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

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

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

Data type: `Boolean`
Data type: `Optional[Boolean]`

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

Default value: `true`
Default value: `undef`

## Data types

Expand Down
4 changes: 4 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@
'path' => $sources_list_d,
'ext' => '.list',
},
'sources' => {
'path' => $sources_list_d,
'ext' => '.sources',
},
},
Boolean $sources_list_force = false,
Hash $source_key_defaults = {
Expand Down
6 changes: 3 additions & 3 deletions manifests/setting.pp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
$setting_type = $title_array[0]
$base_name = join(delete_at($title_array, 0), '-')

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

if $priority !~ Integer {
Expand All @@ -51,7 +51,7 @@
}
}

if ($setting_type == 'list') or ($setting_type == 'pref') {
if $setting_type in ['list', 'pref', 'sources'] {
$_priority = ''
} else {
$_priority = $priority
Expand Down
Loading