c27f0c1c0dcd683699caec9572739157468a57d7
[puppet-modules/puppetlabs-apt.git] / manifests / conf.pp
1 # @summary Specifies a custom Apt configuration file.
2 #
3 # @param content
4 #   Required unless `ensure` is set to 'absent'. Directly supplies content for the configuration file.
5 #
6 # @param ensure
7 #    Specifies whether the configuration file should exist. Valid options: 'present' and 'absent'. 
8 #
9 # @param priority
10 #   Determines the order in which Apt processes the configuration file. Files with lower priority numbers are loaded first. 
11 #   Valid options: a string containing an integer or an integer.
12 #
13 # @param notify_update
14 #   Specifies whether to trigger an `apt-get update` run.
15 #
16 define apt::conf (
17   Optional[String] $content          = undef,
18   Enum['present', 'absent'] $ensure  = present,
19   Variant[String, Integer] $priority = 50,
20   Optional[Boolean] $notify_update   = undef,
21 ) {
22
23   unless $ensure == 'absent' {
24     unless $content {
25       fail('Need to pass in content parameter')
26     }
27   }
28
29   $confheadertmp = epp('apt/_conf_header.epp')
30   apt::setting { "conf-${name}":
31     ensure        => $ensure,
32     priority      => $priority,
33     content       => "${confheadertmp}${content}",
34     notify_update => $notify_update,
35   }
36 }