1 # @summary Manages Apt configuration files.
3 # @see https://docs.puppetlabs.com/references/latest/type.html#file-attributes for more information on source and content parameters
6 # Determines the order in which Apt processes the configuration file. Files with higher priority numbers are loaded first.
9 # Specifies whether the file should exist. Valid options: 'present', 'absent', and 'file'.
12 # Required, unless `content` is set. Specifies a source file to supply the content of the configuration file. Cannot be used in combination
13 # with `content`. Valid options: see link above for Puppet's native file type source attribute.
16 # Required, unless `source` is set. Directly supplies content for the configuration file. Cannot be used in combination with `source`. Valid
17 # options: see link above for Puppet's native file type content attribute.
19 # @param notify_update
20 # Specifies whether to trigger an `apt-get update` run.
23 Variant[String, Integer, Array] $priority = 50,
24 Optional[Enum['file', 'present', 'absent']] $ensure = file,
25 Optional[String] $source = undef,
26 Optional[String] $content = undef,
27 Boolean $notify_update = true,
30 if $content and $source {
31 fail(translate('apt::setting cannot have both content and source'))
34 if !$content and !$source {
35 fail(translate('apt::setting needs either of content or source'))
38 $title_array = split($title, '-')
39 $setting_type = $title_array[0]
40 $base_name = join(delete_at($title_array, 0), '-')
42 assert_type(Pattern[/\Aconf\z/, /\Apref\z/, /\Alist\z/], $setting_type) |$a, $b| {
43 fail(translate("apt::setting resource name/title must start with either 'conf-', 'pref-' or 'list-'"))
46 if $priority !~ Integer {
47 # need this to allow zero-padded priority.
48 assert_type(Pattern[/^\d+$/], $priority) |$a, $b| {
49 fail(translate('apt::setting priority must be an integer or a zero-padded integer'))
53 if ($setting_type == 'list') or ($setting_type == 'pref') {
56 $_priority = $priority
59 $_path = $::apt::config_files[$setting_type]['path']
60 $_ext = $::apt::config_files[$setting_type]['ext']
63 $_notify = Class['apt::update']
68 file { "${_path}/${_priority}${base_name}${_ext}":