diff options
Diffstat (limited to 'manifests/preferences_snippet.pp')
-rw-r--r-- | manifests/preferences_snippet.pp | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/manifests/preferences_snippet.pp b/manifests/preferences_snippet.pp index 6a8e6bc..5ae748b 100644 --- a/manifests/preferences_snippet.pp +++ b/manifests/preferences_snippet.pp @@ -1,33 +1,37 @@ -define apt::preferences_snippet( +define apt::preferences_snippet ( + $priority = undef, $package = false, $ensure = 'present', $source = '', $release = '', - $pin = '', - $priority ) -{ + $pin = '' +) { $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 $ensure == 'present' { + 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") - } + if $priority == undef { + fail('apt::preferences_snippet requires the \'priority\' argument to be set') + } - include apt::preferences + 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') + } + } - concat::fragment{"apt_preference_${name}": + file { "/etc/apt/preferences.d/${name}": ensure => $ensure, - target => '/etc/apt/preferences', + owner => root, group => 0, mode => '0644'; } # This should really work in the same manner as sources_list and apt_conf @@ -37,19 +41,19 @@ define apt::preferences_snippet( '': { case $release { '': { - Concat::Fragment["apt_preference_${name}"]{ - content => template("apt/preferences_snippet.erb") + File["/etc/apt/preferences.d/${name}"]{ + content => template('apt/preferences_snippet.erb') } } default: { - Concat::Fragment["apt_preference_${name}"]{ - content => template("apt/preferences_snippet_release.erb") + File["/etc/apt/preferences.d/${name}"]{ + content => template('apt/preferences_snippet_release.erb') } } } } default: { - Concat::Fragment["apt_preference_${name}"]{ + File["/etc/apt/preferences.d/${name}"]{ source => $source } } |