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,
19 $_before = Apt::Setting["list-${title}"]
22 if $facts['lsbdistcodename'] {
23 $_release = $facts['lsbdistcodename']
25 fail('lsbdistcodename fact not available: release parameter required')
31 if $ensure == 'present' {
33 fail('cannot create a source entry without specifying a location')
35 # Newer oses, do not need the package for HTTPS transport.
36 $_transport_https_releases = [ 'wheezy', 'jessie', 'stretch', 'trusty', 'xenial' ]
37 if $_release in $_transport_https_releases and $location =~ /(?i:^https:\/\/)/ {
38 ensure_packages('apt-transport-https')
42 $includes = merge($::apt::include_defaults, $include)
47 fail('key hash must contain at least an id entry')
49 $_key = merge($::apt::source_key_defaults, $key)
51 $_key = { 'id' => assert_type(String[1], $key) }
55 $header = epp('apt/_header.epp')
57 $sourcelist = epp('apt/source.list.epp', {
58 'comment' => $comment,
59 'includes' => $includes,
60 'opt_architecture' => $architecture,
61 'allow_unsigned' => $allow_unsigned,
62 'location' => $location,
63 'release' => $_release,
67 apt::setting { "list-${name}":
69 content => "${header}${sourcelist}",
70 notify_update => $notify_update,
75 $_pin = merge($pin, { 'ensure' => $ensure, 'before' => $_before })
76 } elsif ($pin =~ Numeric or $pin =~ String) {
77 $url_split = split($location, '[:\/]+')
86 fail('Received invalid value for pin parameter')
88 create_resources('apt::pin', { "${name}" => $_pin })
91 # We do not want to remove keys when the source is absent.
92 if $key and ($ensure == 'present') {
94 apt::key { "Add key: ${$_key['id']} from Apt::Source ${title}":
97 server => $_key['server'],
98 content => $_key['content'],
99 source => $_key['source'],
100 options => $_key['options'],