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')
37 $includes = merge($::apt::include_defaults, $include)
42 fail('key hash must contain at least an id entry')
44 $_key = merge($::apt::source_key_defaults, $key)
46 $_key = { 'id' => assert_type(String[1], $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 ($pin =~ Numeric or $pin =~ String) {
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'],