hold.pp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. # == Define apt::hold
  2. #
  3. # This defined type allows you to hold a package based on the version you
  4. # require. It's implemented by dropping an apt preferences file pinning the
  5. # package to the version you require.
  6. #
  7. # === Parameters
  8. #
  9. # [*version*]
  10. # The version at which you wish to pin a package.
  11. #
  12. # This can either be the full version, such as 4:2.11.8.1-5, or
  13. # a partial version, such as 4:2.11.*
  14. #
  15. # [*package*]
  16. # _default_: +$title+, the title/name of the resource.
  17. #
  18. # Name of the package that apt is to hold.
  19. #
  20. # [*priority*]
  21. # _default_: +1001+
  22. #
  23. # The default priority of 1001 causes this preference to always win. By
  24. # setting the priority to a number greater than 1000 apt will always install
  25. # this version even if it means downgrading the currently installed version.
  26. define apt::hold(
  27. $version,
  28. $ensure = 'present',
  29. $package = $title,
  30. $priority = 1001,
  31. ){
  32. validate_string($title)
  33. validate_re($ensure, ['^present|absent',])
  34. validate_string($package)
  35. validate_string($version)
  36. if ! is_integer($priority) {
  37. fail('$priority must be an integer')
  38. }
  39. if $ensure == 'present' {
  40. ::apt::pin { "hold_${package}":
  41. packages => $package,
  42. version => $version,
  43. priority => $priority,
  44. }
  45. } else {
  46. ::apt::pin { "hold_${package}":
  47. ensure => 'absent',
  48. }
  49. }
  50. }