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 Enum['file', 'present', 'absent'] $ensure = file,
25 Optional[String] $source = undef,
26 Optional[String] $content = undef,
27 Boolean $notify_update = true,
29 if $content and $source {
30 fail('apt::setting cannot have both content and source')
33 if !$content and !$source {
34 fail('apt::setting needs either of content or source')
37 $title_array = split($title, '-')
38 $setting_type = $title_array[0]
39 $base_name = join(delete_at($title_array, 0), '-')
41 assert_type(Pattern[/\Aconf\z/, /\Apref\z/, /\Alist\z/], $setting_type) |$a, $b| {
42 fail("apt::setting resource name/title must start with either 'conf-', 'pref-' or 'list-'")
45 if $priority !~ Integer {
46 # need this to allow zero-padded priority.
47 assert_type(Pattern[/^\d+$/], $priority) |$a, $b| {
48 fail('apt::setting priority must be an integer or a zero-padded integer')
52 if ($setting_type == 'list') or ($setting_type == 'pref') {
55 $_priority = $priority
58 $_path = $apt::config_files[$setting_type]['path']
59 $_ext = $apt::config_files[$setting_type]['ext']
62 $_notify = Class['apt::update']
67 file { "${_path}/${_priority}${base_name}${_ext}":