1 # Defining apt settings
3 Variant[String, Integer, Array] $priority = 50,
4 Optional[Enum['file', 'present', 'absent']] $ensure = file,
5 Optional[String] $source = undef,
6 Optional[String] $content = undef,
7 Boolean $notify_update = true,
10 if $content and $source {
11 fail('apt::setting cannot have both content and source')
14 if !$content and !$source {
15 fail('apt::setting needs either of content or source')
18 $title_array = split($title, '-')
19 $setting_type = $title_array[0]
20 $base_name = join(delete_at($title_array, 0), '-')
22 assert_type(Pattern[/\Aconf\z/, /\Apref\z/, /\Alist\z/], $setting_type) |$a, $b| {
23 fail("apt::setting resource name/title must start with either 'conf-', 'pref-' or 'list-'")
26 if $priority !~ Integer {
27 # need this to allow zero-padded priority.
28 assert_type(Pattern[/^\d+$/], $priority) |$a, $b| {
29 fail('apt::setting priority must be an integer or a zero-padded integer')
33 if ($setting_type == 'list') or ($setting_type == 'pref') {
36 $_priority = $priority
39 $_path = $::apt::config_files[$setting_type]['path']
40 $_ext = $::apt::config_files[$setting_type]['ext']
43 $_notify = Class['apt::update']
48 file { "${_path}/${_priority}${base_name}${_ext}":