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,
15 Optional[String] $key_server = undef,
16 Optional[String] $key_content = undef,
17 Optional[String] $key_source = undef,
18 Optional[Boolean] $include_src = undef,
19 Optional[Boolean] $include_deb = undef,
20 $required_packages = undef,
21 $trusted_source = undef,
24 # This is needed for compat with 1.8.x
27 $_before = Apt::Setting["list-${title}"]
29 if $required_packages != undef {
30 deprecation('apt $required_packages', '$required_packages is deprecated and will be removed in the next major release, please use package resources instead.')
31 exec { "Required packages: '${required_packages}' for ${name}":
32 command => "${::apt::provider} -y install ${required_packages}",
33 logoutput => 'on_failure',
41 if $trusted_source != undef {
42 deprecation('apt $trusted_source', '$trusted_source is deprecated and will be removed in the next major release, please use $allow_unsigned instead.')
43 $_allow_unsigned = $trusted_source
45 $_allow_unsigned = $allow_unsigned
49 if $facts['lsbdistcodename'] {
50 $_release = $facts['lsbdistcodename']
52 fail('lsbdistcodename fact not available: release parameter required')
58 if $ensure == 'present' and ! $location {
59 fail('cannot create a source entry without specifying a location')
62 if $include_src != undef and $include_deb != undef {
63 $_deprecated_include = {
64 'src' => $include_src,
65 'deb' => $include_deb,
67 } elsif $include_src != undef {
68 $_deprecated_include = { 'src' => $include_src }
69 } elsif $include_deb != undef {
70 $_deprecated_include = { 'deb' => $include_deb }
72 $_deprecated_include = {}
75 $includes = merge($::apt::include_defaults, $_deprecated_include, $include)
78 'key_server' => $key_server,
79 'key_content' => $key_content,
80 'key_source' => $key_source,
86 fail('key hash must contain at least an id entry')
88 $_key = merge($::apt::source_key_defaults, $_deprecated_key, $key)
90 validate_legacy(String, 'validate_string', $key)
91 $_key = merge( { 'id' => $key }, $_deprecated_key)
95 $header = epp('apt/_header.epp')
97 $sourcelist = epp('apt/source.list.epp', {
98 'comment' => $comment,
99 'includes' => $includes,
100 'architecture' => $architecture,
101 'allow_unsigned' => $_allow_unsigned,
102 'location' => $location,
103 'release' => $_release,
107 apt::setting { "list-${name}":
109 content => "${header}${sourcelist}",
110 notify_update => $notify_update,
115 $_pin = merge($pin, { 'ensure' => $ensure, 'before' => $_before })
116 } elsif (is_numeric($pin) or is_string($pin)) {
117 $url_split = split($location, '[:\/]+')
118 $host = $url_split[1]
122 'before' => $_before,
126 fail('Received invalid value for pin parameter')
128 create_resources('apt::pin', { "${name}" => $_pin })
131 # We do not want to remove keys when the source is absent.
132 if $key and ($ensure == 'present') {
134 apt::key { "Add key: ${$_key['id']} from Apt::Source ${title}":
137 server => $_key['server'],
138 content => $_key['content'],
139 source => $_key['source'],
140 options => $_key['options'],
141 key_server => $_key['key_server'],
142 key_content => $_key['key_content'],
143 key_source => $_key['key_source'],