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,
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' and ! $location {
33 fail('cannot create a source entry without specifying a location')
36 $includes = merge($::apt::include_defaults, $include)
41 fail('key hash must contain at least an id entry')
43 $_key = merge($::apt::source_key_defaults, $key)
45 validate_legacy(String, 'validate_string', $key)
46 $_key = { 'id' => $key }
50 $header = epp('apt/_header.epp')
52 $sourcelist = epp('apt/source.list.epp', {
53 'comment' => $comment,
54 'includes' => $includes,
55 'opt_architecture' => $architecture,
56 'allow_unsigned' => $allow_unsigned,
57 'location' => $location,
58 'release' => $_release,
62 apt::setting { "list-${name}":
64 content => "${header}${sourcelist}",
65 notify_update => $notify_update,
70 $_pin = merge($pin, { 'ensure' => $ensure, 'before' => $_before })
71 } elsif (is_numeric($pin) or is_string($pin)) {
72 $url_split = split($location, '[:\/]+')
81 fail('Received invalid value for pin parameter')
83 create_resources('apt::pin', { "${name}" => $_pin })
86 # We do not want to remove keys when the source is absent.
87 if $key and ($ensure == 'present') {
89 apt::key { "Add key: ${$_key['id']} from Apt::Source ${title}":
92 server => $_key['server'],
93 content => $_key['content'],
94 source => $_key['source'],
95 options => $_key['options'],