4 Optional[Variant[String, Stdlib::Compat::String]] $location = undef,
5 Variant[String, Stdlib::Compat::String] $comment = $name,
6 Variant[String, Stdlib::Compat::String] $ensure = present,
7 Optional[Variant[String, Stdlib::Compat::String]] $release = undef,
8 Variant[String, Stdlib::Compat::String] $repos = 'main',
9 Optional[Variant[Hash, Stdlib::Compat::Hash]] $include = {},
10 Optional[Variant[String, Stdlib::Compat::String, Hash, Stdlib::Compat::Hash]] $key = undef,
12 Optional[Variant[String, Stdlib::Compat::String]] $architecture = undef,
13 Boolean $allow_unsigned = false,
14 Boolean $notify_update = true,
15 Optional[Variant[String, Stdlib::Compat::String]] $key_server = undef,
16 Optional[Variant[String, Stdlib::Compat::String]] $key_content = undef,
17 Optional[Variant[String, Stdlib::Compat::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 validate_legacy(String, 'validate_string', $architecture, $comment, $location, $repos)
25 validate_legacy(Boolean, 'validate_bool', $allow_unsigned)
26 validate_legacy(Hash, 'validate_hash', $include)
28 # This is needed for compat with 1.8.x
31 $_before = Apt::Setting["list-${title}"]
33 if $required_packages != undef {
34 deprecation('apt $required_packages', '$required_packages is deprecated and will be removed in the next major release, please use package resources instead.')
35 exec { "Required packages: '${required_packages}' for ${name}":
36 command => "${::apt::provider} -y install ${required_packages}",
37 logoutput => 'on_failure',
45 if $trusted_source != undef {
46 deprecation('apt $trusted_source', '$trusted_source is deprecated and will be removed in the next major release, please use $allow_unsigned instead.')
47 $_allow_unsigned = $trusted_source
49 $_allow_unsigned = $allow_unsigned
53 if $facts['lsbdistcodename'] {
54 $_release = $facts['lsbdistcodename']
56 fail('lsbdistcodename fact not available: release parameter required')
62 if $ensure == 'present' and ! $location {
63 fail('cannot create a source entry without specifying a location')
66 if $include_src != undef and $include_deb != undef {
67 $_deprecated_include = {
68 'src' => $include_src,
69 'deb' => $include_deb,
71 } elsif $include_src != undef {
72 $_deprecated_include = { 'src' => $include_src }
73 } elsif $include_deb != undef {
74 $_deprecated_include = { 'deb' => $include_deb }
76 $_deprecated_include = {}
79 $includes = merge($::apt::include_defaults, $_deprecated_include, $include)
82 'key_server' => $key_server,
83 'key_content' => $key_content,
84 'key_source' => $key_source,
90 fail('key hash must contain at least an id entry')
92 $_key = merge($::apt::source_key_defaults, $_deprecated_key, $key)
94 validate_legacy(String, 'validate_string', $key)
95 $_key = merge( { 'id' => $key }, $_deprecated_key)
99 $header = epp('apt/_header.epp')
101 $sourcelist = epp('apt/source.list.epp', {
102 'comment' => $comment,
103 'includes' => $includes,
104 'architecture' => $architecture,
105 'allow_unsigned' => $_allow_unsigned,
106 'location' => $location,
107 'release' => $_release,
111 apt::setting { "list-${name}":
113 content => "${header}${sourcelist}",
114 notify_update => $notify_update,
119 $_pin = merge($pin, { 'ensure' => $ensure, 'before' => $_before })
120 } elsif (is_numeric($pin) or is_string($pin)) {
121 $url_split = split($location, '[:\/]+')
122 $host = $url_split[1]
126 'before' => $_before,
130 fail('Received invalid value for pin parameter')
132 create_resources('apt::pin', { "${name}" => $_pin })
135 # We do not want to remove keys when the source is absent.
136 if $key and ($ensure == 'present') {
138 apt::key { "Add key: ${$_key['id']} from Apt::Source ${title}":
141 server => $_key['server'],
142 content => $_key['content'],
143 source => $_key['source'],
144 options => $_key['options'],
145 key_server => $_key['key_server'],
146 key_content => $_key['key_content'],
147 key_source => $_key['key_source'],