4 Optional[String] $location = undef,
5 String $comment = $name,
6 String $ensure = present,
7 Optional[String] $release = undef,
8 String $repos = 'main',
9 Optional[Variant[Hash]] $include = {},
10 Optional[Variant[String, Hash]] $key = undef,
11 Optional[Variant[Hash, Numeric, String]] $pin = undef,
12 Optional[String] $architecture = undef,
13 Boolean $allow_unsigned = false,
14 Boolean $notify_update = true,
17 # This is needed for compat with 1.8.x
20 $_before = Apt::Setting["list-${title}"]
23 if $facts['lsbdistcodename'] {
24 $_release = $facts['lsbdistcodename']
26 fail('lsbdistcodename fact not available: release parameter required')
32 if $ensure == 'present' {
34 fail('cannot create a source entry without specifying a location')
35 } elsif $_release == 'jessie' {
36 $method = split($location, '[:\/]+')[0]
37 if $method == 'https' {
38 ensure_packages('apt-transport-https')
43 $includes = merge($::apt::include_defaults, $include)
48 fail('key hash must contain at least an id entry')
50 $_key = merge($::apt::source_key_defaults, $key)
52 $_key = { 'id' => assert_type(String[1], $key) }
56 $header = epp('apt/_header.epp')
58 $sourcelist = epp('apt/source.list.epp', {
59 'comment' => $comment,
60 'includes' => $includes,
61 'opt_architecture' => $architecture,
62 'allow_unsigned' => $allow_unsigned,
63 'location' => $location,
64 'release' => $_release,
68 apt::setting { "list-${name}":
70 content => "${header}${sourcelist}",
71 notify_update => $notify_update,
76 $_pin = merge($pin, { 'ensure' => $ensure, 'before' => $_before })
77 } elsif ($pin =~ Numeric or $pin =~ String) {
78 $url_split = split($location, '[:\/]+')
87 fail('Received invalid value for pin parameter')
89 create_resources('apt::pin', { "${name}" => $_pin })
92 # We do not want to remove keys when the source is absent.
93 if $key and ($ensure == 'present') {
95 apt::key { "Add key: ${$_key['id']} from Apt::Source ${title}":
98 server => $_key['server'],
99 content => $_key['content'],
100 source => $_key['source'],
101 options => $_key['options'],