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 # Some releases do not support https transport with default installation
33 $_transport_https_releases = [ 'wheezy', 'jessie', 'stretch', 'trusty', 'xenial' ]
35 if $ensure == 'present' {
37 fail('cannot create a source entry without specifying a location')
38 } elsif $_release in $_transport_https_releases {
39 $method = split($location, '[:\/]+')[0]
40 if $method == 'https' {
41 ensure_packages('apt-transport-https')
46 $includes = merge($::apt::include_defaults, $include)
51 fail('key hash must contain at least an id entry')
53 $_key = merge($::apt::source_key_defaults, $key)
55 $_key = { 'id' => assert_type(String[1], $key) }
59 $header = epp('apt/_header.epp')
61 $sourcelist = epp('apt/source.list.epp', {
62 'comment' => $comment,
63 'includes' => $includes,
64 'opt_architecture' => $architecture,
65 'allow_unsigned' => $allow_unsigned,
66 'location' => $location,
67 'release' => $_release,
71 apt::setting { "list-${name}":
73 content => "${header}${sourcelist}",
74 notify_update => $notify_update,
79 $_pin = merge($pin, { 'ensure' => $ensure, 'before' => $_before })
80 } elsif ($pin =~ Numeric or $pin =~ String) {
81 $url_split = split($location, '[:\/]+')
90 fail('Received invalid value for pin parameter')
92 create_resources('apt::pin', { "${name}" => $_pin })
95 # We do not want to remove keys when the source is absent.
96 if $key and ($ensure == 'present') {
98 apt::key { "Add key: ${$_key['id']} from Apt::Source ${title}":
101 server => $_key['server'],
102 content => $_key['content'],
103 source => $_key['source'],
104 options => $_key['options'],