source: src/puppetcode/environments/test/modules/apt/manifests/setting.pp@ 9b55b08

0.5 app-cordova debian/bullseye debian/jessie
Last change on this file since 9b55b08 was 1c22429, checked in by Joachim Langenbach <joachim.langenbach@…>, 10 years ago
  • gnuboat_epd adds the apt repository from gnuboat to install epd-fuse package
  • Property mode set to 100644
File size: 1.6 KB
Line 
1define apt::setting (
2 $priority = 50,
3 $ensure = file,
4 $source = undef,
5 $content = undef,
6 $notify_update = true,
7) {
8
9 include 'apt::params'
10 if $content and $source {
11 fail('apt::setting cannot have both content and source')
12 }
13
14 if !$content and !$source {
15 fail('apt::setting needs either of content or source')
16 }
17
18 validate_re($ensure, ['file', 'present', 'absent'])
19 validate_bool($notify_update)
20
21 $title_array = split($title, '-')
22 $setting_type = $title_array[0]
23 $base_name = join(delete_at($title_array, 0), '-')
24
25 validate_re($setting_type, ['\Aconf\z', '\Apref\z', '\Alist\z'], "apt::setting resource name/title must start with either 'conf-', 'pref-' or 'list-'")
26
27 unless is_integer($priority) {
28 # need this to allow zero-padded priority.
29 validate_re($priority, '^\d+$', 'apt::setting priority must be an integer or a zero-padded integer')
30 }
31
32 if $source {
33 validate_string($source)
34 }
35
36 if $content {
37 validate_string($content)
38 }
39
40 if ($setting_type == 'list') or ($setting_type == 'pref') {
41 $_priority = ''
42 } else {
43 $_priority = $priority
44 }
45
46 $_path = $::apt::params::config_files[$setting_type]['path']
47 $_ext = $::apt::params::config_files[$setting_type]['ext']
48
49 if $notify_update {
50 $_notify = Class['apt::update']
51 } else {
52 $_notify = undef
53 }
54
55 file { "${_path}/${_priority}${base_name}${_ext}":
56 ensure => $ensure,
57 owner => 'root',
58 group => 'root',
59 mode => '0644',
60 content => $content,
61 source => $source,
62 notify => $_notify,
63 }
64}
Note: See TracBrowser for help on using the repository browser.