Skip to content

Commit 79b1ff6

Browse files
committed
Initial testing for deb822 APT sources
1 parent 9b6aa36 commit 79b1ff6

File tree

5 files changed

+204
-1
lines changed

5 files changed

+204
-1
lines changed

manifests/params.pp

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# @summary Provides defaults for the Apt module parameters.
2+
#
3+
# @api private
4+
#
5+
class apt::params {
6+
if $facts['os']['family'] != 'Debian' {
7+
fail('This module only works on Debian or derivatives like Ubuntu')
8+
}
9+
10+
$root = '/etc/apt'
11+
$provider = '/usr/bin/apt-get'
12+
$sources_list = "${root}/sources.list"
13+
$sources_list_force = false
14+
$sources_list_d = "${root}/sources.list.d"
15+
$trusted_gpg_d = "${root}/trusted.gpg.d"
16+
$conf_d = "${root}/apt.conf.d"
17+
$preferences = "${root}/preferences"
18+
$preferences_d = "${root}/preferences.d"
19+
$apt_conf_d = "${root}/apt.conf.d"
20+
$keyserver = 'keyserver.ubuntu.com'
21+
$key_options = undef
22+
$confs = {}
23+
$update = {}
24+
$purge = {}
25+
$proxy = {}
26+
$sources = {}
27+
$keys = {}
28+
$ppas = {}
29+
$pins = {}
30+
$settings = {}
31+
$manage_auth_conf = true
32+
$auth_conf_entries = []
33+
34+
$config_files = {
35+
'conf' => {
36+
'path' => $conf_d,
37+
'ext' => '',
38+
},
39+
'pref' => {
40+
'path' => $preferences_d,
41+
'ext' => '.pref',
42+
},
43+
'list' => {
44+
'path' => $sources_list_d,
45+
'ext' => '.list',
46+
},
47+
'source' => {
48+
'path' => $sources_list_d,
49+
'ext' => '.sources',
50+
},
51+
}
52+
53+
$update_defaults = {
54+
'frequency' => 'reluctantly',
55+
'loglevel' => undef,
56+
'timeout' => undef,
57+
'tries' => undef,
58+
}
59+
60+
$proxy_defaults = {
61+
'ensure' => undef,
62+
'host' => undef,
63+
'port' => 8080,
64+
'https' => false,
65+
'https_acng' => false,
66+
'direct' => false,
67+
}
68+
69+
$purge_defaults = {
70+
'sources.list' => false,
71+
'sources.list.d' => false,
72+
'preferences' => false,
73+
'preferences.d' => false,
74+
'apt.conf.d' => false,
75+
}
76+
77+
$include_defaults = {
78+
'deb' => true,
79+
'src' => false,
80+
}
81+
82+
case $facts['os']['name'] {
83+
'Debian': {
84+
$backports = {
85+
'location' => 'http://deb.debian.org/debian',
86+
'repos' => 'main contrib non-free',
87+
}
88+
$ppa_options = undef
89+
$ppa_package = undef
90+
$auth_conf_owner = '_apt'
91+
}
92+
'Ubuntu': {
93+
$backports = {
94+
'location' => 'http://archive.ubuntu.com/ubuntu',
95+
'repos' => 'main universe multiverse restricted',
96+
}
97+
$ppa_options = ['-y']
98+
$ppa_package = 'software-properties-common'
99+
$auth_conf_owner = '_apt'
100+
}
101+
undef: {
102+
fail('Unable to determine value for fact os[\"name\"]')
103+
}
104+
default: {
105+
$ppa_options = undef
106+
$ppa_package = undef
107+
$backports = undef
108+
$auth_conf_owner = 'root'
109+
}
110+
}
111+
}

manifests/setting.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
}
5050
}
5151

52-
if ($setting_type == 'list') or ($setting_type == 'pref') {
52+
if ($setting_type == 'list') or ($setting_type == 'pref') or ($setting_type == 'source') {
5353
$_priority = ''
5454
} else {
5555
$_priority = $priority

manifests/source_deb822.pp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# @summary A short summary of the purpose of this defined type.
2+
#
3+
# A description of what this defined type does
4+
#
5+
# @example
6+
# apt::source_deb822 { 'namevar': }
7+
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',
13+
String $comment = $name,
14+
Boolean $enabled = true,
15+
Boolean $notify_update = true,
16+
Optional[Array[String]] $architectures = undef,
17+
Optional[Boolean] $allow_insecure = undef,
18+
Optional[Boolean] $trusted = undef,
19+
Optional[Variant[Array[Stdlib::AbsolutePath], String]] $signed_by = undef,
20+
Optional[Boolean] $check_valid_until = undef,
21+
Optional[Hash] $options = undef
22+
) {
23+
$header = epp('apt/_header.epp')
24+
$source_content = epp('apt/source_deb822.epp')
25+
26+
apt::setting { "source-${name}":
27+
ensure => $ensure,
28+
content => "${header}${source_content}",
29+
notify_update => $notify_update,
30+
}
31+
}

spec/defines/source_deb822_spec.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# frozen_string_literal: true
2+
3+
require 'spec_helper'
4+
5+
describe 'apt::source_deb822' do
6+
let(:title) { 'namevar' }
7+
let(:params) do
8+
{}
9+
end
10+
11+
on_supported_os.each do |os, os_facts|
12+
context "on #{os}" do
13+
let(:facts) { os_facts }
14+
15+
it { is_expected.to compile }
16+
end
17+
end
18+
end

templates/source_deb822.epp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<% | String $comment,
2+
Enum['yes','no'] $enabled,
3+
Hash $types,Array[String] $uris,
4+
Array[String] $suites,
5+
Array[String] $components,
6+
Optional[Array] $architectures = undef,
7+
Optional[Enum['yes','no']] $allow_insecure = undef,
8+
Optional[Enum['yes','no']] $repo_trusted = undef,
9+
Optional[Enum['yes','no']] $check_valid_until = undef,
10+
Optional[Variant[Array[String], String]] $signed_by = undef,
11+
Optional[Hash] $options = undef
12+
| -%>
13+
# This file is managed by Puppet. DO NOT EDIT.
14+
# <%= $comment %>
15+
Enabled: <%= $enabled %>
16+
Types:<% if $types['deb'] { %> deb<% } %><% if $types['src'] { %> deb-src<% } %>
17+
URIs: <% $uris.each | String $uri | { -%> <%= $uri %> <% } %>
18+
Suites: <% $suites.each | String $suite | { -%> <%= $suite %> <% } %>
19+
Components: <% $components.each | String $component | { -%> <%= $component %> <% } %>
20+
<% if $architectures { -%>
21+
Architectures:<% $architectures.each | String $arch | { %> <%= $arch %><% } %>
22+
<%- } -%>
23+
<% if $allow_insecure { -%>
24+
Allow-Insecure: <%= $allow_insecure %>
25+
<% } -%>
26+
<% if $repo_trusted { -%>
27+
Trusted: <%= $repo_trusted %>
28+
<% } -%>
29+
<% if $check_valid_until { -%>
30+
Check-Valid-Until: <%= $check_valid_until %>
31+
<% } -%>
32+
<% if $signed_by { -%>
33+
Signed-By: <% if type($signed_by) =~ Type[Array] { -%><%- $signed_by.each |String $keyring| { -%><%= $keyring %> <% } %>
34+
<%- } -%>
35+
<%- elsif type($signed_by) =~ Type[String] { %>
36+
<%= $signed_by -%>
37+
<%- }} -%>
38+
<% if $options { -%>
39+
# Additional Options
40+
<% $options.each |$key, $value| {-%>
41+
<%= $key -%>: <%= $value %>
42+
<% } -%>
43+
<% } -%>

0 commit comments

Comments
 (0)