diff options
Diffstat (limited to 'manifests/preferences_snippet.pp')
-rw-r--r-- | manifests/preferences_snippet.pp | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/manifests/preferences_snippet.pp b/manifests/preferences_snippet.pp index 4b8e575..6a8e6bc 100644 --- a/manifests/preferences_snippet.pp +++ b/manifests/preferences_snippet.pp @@ -1,21 +1,33 @@ define apt::preferences_snippet( + $package = false, $ensure = 'present', $source = '', - $release, + $release = '', + $pin = '', $priority ) { + $real_package = $package ? { + false => $name, + default => $package, + } + if $custom_preferences == false { fail("Trying to define a preferences_snippet with \$custom_preferences set to false.") } + if !$pin and !$release { + fail("apt::preferences_snippet requires one of the 'pin' or 'release' argument to be set") + } + if $pin and $release { + fail("apt::preferences_snippet requires either a 'pin' or 'release' argument, not both") + } + include apt::preferences - file { "${apt::preferences::apt_preferences_dir}/${name}": + concat::fragment{"apt_preference_${name}": ensure => $ensure, - #TODO this template is somewhat limited - notify => Exec["concat_${apt::preferences::apt_preferences_dir}"], - owner => root, group => 0, mode => 0600; + target => '/etc/apt/preferences', } # This should really work in the same manner as sources_list and apt_conf @@ -23,12 +35,21 @@ define apt::preferences_snippet( # lenny, we can't generalize without going into ugly special-casing. case $source { '': { - File["${apt::preferences::apt_preferences_dir}/${name}"] { - content => template("apt/preferences_snippet.erb") + case $release { + '': { + Concat::Fragment["apt_preference_${name}"]{ + content => template("apt/preferences_snippet.erb") + } + } + default: { + Concat::Fragment["apt_preference_${name}"]{ + content => template("apt/preferences_snippet_release.erb") + } + } } } default: { - File["${apt::preferences::apt_preferences_dir}/${name}"] { + Concat::Fragment["apt_preference_${name}"]{ source => $source } } |