diff options
author | Micah <micah@leap.se> | 2016-05-24 10:19:22 -0400 |
---|---|---|
committer | Micah <micah@leap.se> | 2016-05-24 10:19:22 -0400 |
commit | aba291e2de1682620b6dc22446b30fe870b62956 (patch) | |
tree | 1ba5e08c285dbf2b60e7be2f59934e6abd5f866c /manifests/preferences_snippet.pp |
Squashed 'puppet/modules/apt/' content from commit 33c61e8
git-subtree-dir: puppet/modules/apt
git-subtree-split: 33c61e8df59db1abbed379a9e9790946060a8f1e
Diffstat (limited to 'manifests/preferences_snippet.pp')
-rw-r--r-- | manifests/preferences_snippet.pp | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/manifests/preferences_snippet.pp b/manifests/preferences_snippet.pp new file mode 100644 index 00000000..b7dba0d8 --- /dev/null +++ b/manifests/preferences_snippet.pp @@ -0,0 +1,59 @@ +define apt::preferences_snippet ( + $priority = undef, + $package = false, + $ensure = 'present', + $source = '', + $release = '', + $pin = '' +) { + + $real_package = $package ? { + false => $name, + default => $package, + } + + if $ensure == 'present' { + if $apt::custom_preferences == false { + fail('Trying to define a preferences_snippet with $custom_preferences set to false.') + } + + if $priority == undef { + fail('apt::preferences_snippet requires the \'priority\' argument to be set') + } + + 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') + } + } + + file { "/etc/apt/preferences.d/${name}": + ensure => $ensure, + owner => root, group => 0, mode => '0644', + before => Exec['apt_updated']; + } + + case $source { + '': { + case $release { + '': { + File["/etc/apt/preferences.d/${name}"]{ + content => template('apt/preferences_snippet.erb') + } + } + default: { + File["/etc/apt/preferences.d/${name}"]{ + content => template('apt/preferences_snippet_release.erb') + } + } + } + } + default: { + File["/etc/apt/preferences.d/${name}"]{ + source => $source + } + } + } +} |