Skip to content

Commit c74f6f6

Browse files
committed
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
1 parent 9f0415e commit c74f6f6

File tree

3 files changed

+35
-20
lines changed

3 files changed

+35
-20
lines changed

manifests/setting.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
$setting_type = $title_array[0]
3939
$base_name = join(delete_at($title_array, 0), '-')
4040

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

manifests/source_deb822.pp

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,44 @@
55
# @example
66
# apt::source_deb822 { 'namevar': }
77
define apt::source_deb822 (
8-
Array[String] $uris,
9-
Array[String] $suites,
10-
Array[String] $components,
11-
Array[Enum['deb','deb-src'], 1, 2] $types = ['deb'],
12-
Enum['present','absent'] $ensure = 'present',
138
String $comment = $name,
149
Boolean $enabled = true,
10+
Array[Enum['deb','deb-src'], 1, 2] $types = ['deb'],
1511
Boolean $notify_update = true,
12+
Enum['present','absent'] $ensure = 'present',
13+
Optional[Array[String]] $uris = undef,
14+
Optional[Array[String]] $suites = undef,
15+
Optional[Array[String]] $components = undef,
1616
Optional[Array[String]] $architectures = undef,
1717
Optional[Boolean] $allow_insecure = undef,
18-
Optional[Boolean] $trusted = undef,
19-
Optional[Variant[Array[Stdlib::AbsolutePath], String]] $signed_by = undef,
18+
Optional[Boolean] $repo_trusted = undef,
19+
Optional[Variant[Array[Stdlib::AbsolutePath],String]] $signed_by = undef,
2020
Optional[Boolean] $check_valid_until = undef,
21-
Optional[Hash] $options = undef
2221
) {
23-
$header = epp('apt/_header.epp')
24-
$source_content = epp('apt/source_deb822.epp')
22+
case $ensure {
23+
'present': {
24+
$header = epp('apt/_header.epp')
25+
$source_content = epp('apt/source_deb822.epp', delete_undef_values({
26+
'uris' => $uris,
27+
'suites' => $suites,
28+
'components' => $components,
29+
'types' => $types,
30+
'comment' => $comment,
31+
'enabled' => $enabled ? { true => 'yes', false => 'no' },
32+
'architectures' => $architectures,
33+
'allow_insecure' => $allow_insecure ? { true => 'yes', false => 'no', default => undef },
34+
'repo_trusted' => $repo_trusted ? { true => 'yes', false => 'no', default => undef },
35+
'check_valid_until' => $check_valid_until ? { true => 'yes', false => 'no', default => undef },
36+
'signed_by' => $signed_by,
37+
}
38+
)
39+
)
40+
}
41+
'absent': {
42+
$header = undef
43+
$source_content = undef
44+
}
45+
}
2546

2647
apt::setting { "source-${name}":
2748
ensure => $ensure,

templates/source_deb822.epp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<% | String $comment,
22
Enum['yes','no'] $enabled,
3-
Hash $types,Array[String] $uris,
3+
Array[String] $types,
4+
Array[String] $uris,
45
Array[String] $suites,
56
Array[String] $components,
67
Optional[Array] $architectures = undef,
@@ -10,10 +11,9 @@
1011
Optional[Variant[Array[String], String]] $signed_by = undef,
1112
Optional[Hash] $options = undef
1213
| -%>
13-
# This file is managed by Puppet. DO NOT EDIT.
1414
# <%= $comment %>
1515
Enabled: <%= $enabled %>
16-
Types:<% if $types['deb'] { %> deb<% } %><% if $types['src'] { %> deb-src<% } %>
16+
Types: <% $types.each |String $type| { -%> <%= $type %> <% } %>
1717
URIs: <% $uris.each | String $uri | { -%> <%= $uri %> <% } %>
1818
Suites: <% $suites.each | String $suite | { -%> <%= $suite %> <% } %>
1919
Components: <% $components.each | String $component | { -%> <%= $component %> <% } %>
@@ -35,9 +35,3 @@ Signed-By: <% if type($signed_by) =~ Type[Array] { -%><%- $signed_by.each |Strin
3535
<%- elsif type($signed_by) =~ Type[String] { %>
3636
<%= $signed_by -%>
3737
<%- }} -%>
38-
<% if $options { -%>
39-
# Additional Options
40-
<% $options.each |$key, $value| {-%>
41-
<%= $key -%>: <%= $value %>
42-
<% } -%>
43-
<% } -%>

0 commit comments

Comments
 (0)